简体   繁体   中英

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. 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

note: ******* is any condition

You are writing wrong sql query syntax. Your sql query should be something like:

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. 1. You have the closing ) but never opened it. 2. Include the default value in your query

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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