我正在尝试从两个不同的表中插入包含WHERE的语句:
我要插入的表是dbo.order
其他两个表是:
我试过的陈述是
insert into dbo.order
(customer_id,package_id,notes)
Select user_id,Package_ID
from
dbo.users,dbo.packages
where
username = 'bader' AND package_name = 'beginner','notes value here';
有什么建议吗?
答案 0 :(得分:2)
此处没有明显的联接,因此您将获得Bader订单和初学者套餐的笛卡尔产品。不确定音符值应该是多少。如果它是文字,你可以将它包含在select子句中。
insert into dbo.order
(customer_id,package_id,notes)
Select
user_id,Package_ID , 'notes value here'
from
dbo.users,dbo.packages
where
username = 'bader' AND package_name = 'beginner';
答案 1 :(得分:1)
insert into dbo.order
(customer_id,package_id,notes)
Select user_id, Package_ID, 'notes value here'
from
dbo.users, dbo.packages
where
username = 'bader' AND package_name = 'beginner';