简体   繁体   English

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

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

guys im trying to insert into a table with multiple value. 伙计们即时通讯试图插入到具有多个值的表。

i want insert into purchasing table where customerID is gained from Customer table and the SourceID is always 1 because it its default. 我想插入到购买表中,其中从客户表中获得了客户ID,并且源ID始终为1,因为它是默认值。 i try query like this 我尝试这样查询

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

but it returns erorr, can u guys help me, how to insert into table with multiple select and default insert 但是它返回erorr,你们能帮我吗,如何通过多次选择和默认插入来插入表

note: ******* is any condition 注意: *******是任何条件

You are writing wrong sql query syntax. 您正在编写错误的sql查询语法。 Your sql query should be something like: 您的SQL查询应该是这样的:

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

尝试select customerID, 1 from Customer

It is due to you have couple of errors in your sql. 这是由于您的sql中有几个错误。 1. You have the closing ) but never opened it. 1.您已关闭),但从未打开过。 2. Include the default value in your query 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