如何为多个状态插入新记录
How to insert new record for multiple states
我有一个 table,其中包含各种状态信息。 table 中存在冗余,但它位于生产服务器上,因此我无权进行更改。
这是 table 中的数据示例:
有没有办法为 table 中的每个州插入一个新行?相同的信息将进入每一行,唯一的区别是州名。所以在上面的 table 示例中,有 3 个状态,因此需要添加 3 个新行..
也许..
INSERT INTO myTable
(State,Shop,Platform,Additional)
Select distinct
State,
'info1',
'info2',
'info3'
from myTable
将为每个州 return 一行并插入所有具有相同信息的行
您可以只从 table select distinct State
并将它们和其他值插入回 table,如下所示:
insert into your_Table (State, Shop, Platform, Additional_Information)
select distinct State, @Shop_To_Insert, @Platform_To_Insert, @Information
from your_Table
我有一个 table,其中包含各种状态信息。 table 中存在冗余,但它位于生产服务器上,因此我无权进行更改。
这是 table 中的数据示例:
有没有办法为 table 中的每个州插入一个新行?相同的信息将进入每一行,唯一的区别是州名。所以在上面的 table 示例中,有 3 个状态,因此需要添加 3 个新行..
也许..
INSERT INTO myTable
(State,Shop,Platform,Additional)
Select distinct
State,
'info1',
'info2',
'info3'
from myTable
将为每个州 return 一行并插入所有具有相同信息的行
您可以只从 table select distinct State
并将它们和其他值插入回 table,如下所示:
insert into your_Table (State, Shop, Platform, Additional_Information)
select distinct State, @Shop_To_Insert, @Platform_To_Insert, @Information
from your_Table