繁体   English   中英

使用选择和多值SQL Server插入表

[英]Insert into table With select and multiple value SQL server

伙计们即时通讯试图插入到具有多个值的表。

我想插入到购买表中,其中从客户表中获得了客户ID,并且源ID始终为1,因为它是默认值。 我尝试这样查询

insert into purchasing (customerID,SourceID) select customerID from Customer where    ************,'1'

但是它返回erorr,你们能帮我吗,如何通过多次选择和默认插入来插入表

注意: *******是任何条件

您正在编写错误的sql查询语法。 您的SQL查询应该是这样的:

insert into purchasing (customerID,SourceID) select customerID, 1 from Customer where *** 

尝试select customerID, 1 from Customer

这是由于您的sql中有几个错误。 1.您已关闭),但从未打开过。 2.在查询中包括默认值

insert into purchasing (customerID,SourceID) select customerID, 1 from Customer where ???

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM