我希望将 table 2 中的一些数据和一些常量插入到 Table1 中
I wish to insert into Table1, some data and some constants from table 2
下面是我正在使用的代码。 sellingprice、type、BandID 和 IsPercent 是常量
我希望插入多行,因为有多个产品的描述为 XYZ
Insert into Table1 ([itemid],[SellingPrice],[Type],[BandID],[IsPercent])
values
((select ID from Table2 where Description like '%XYZ%'),26.5,0,20,1);
但我收到错误 'Subquery returned more than 1 value'
如何使用其他列值的常量从一个 table 而非全部插入多个值?
你可以这样试试
Insert into Table1 ([itemid],[SellingPrice],[Type],[BandID],[IsPercent])
select ID as itemid, 26.5 as SellingPrice,0 as Type,20 as BandID,1 as IsPercent
from Table2
where Description like '%XYZ%';
下面是我正在使用的代码。 sellingprice、type、BandID 和 IsPercent 是常量 我希望插入多行,因为有多个产品的描述为 XYZ
Insert into Table1 ([itemid],[SellingPrice],[Type],[BandID],[IsPercent])
values
((select ID from Table2 where Description like '%XYZ%'),26.5,0,20,1);
但我收到错误 'Subquery returned more than 1 value' 如何使用其他列值的常量从一个 table 而非全部插入多个值?
你可以这样试试
Insert into Table1 ([itemid],[SellingPrice],[Type],[BandID],[IsPercent])
select ID as itemid, 26.5 as SellingPrice,0 as Type,20 as BandID,1 as IsPercent
from Table2
where Description like '%XYZ%';