Last post Dec 27, 2013 02:37 AM by George Qiao
Dec 26, 2013 08:20 AM|xuan308|LINK
Cart table(cartId, prodId)
I have multiple record with same prodId and I want to insert them into another table called OrderDetails(detailsId, prodId)
Example I have 3 records with same prodId in Cart table, I want retrieve them and insert 3 records into OrderDetails table.
How can I do it?
Dec 26, 2013 08:41 AM|dexononforum|LINK
Insert into OrderDetails(detailsId, prodId)
select NEWID(),prodiid from Card
NEWID() - Primary key of table.
Dec 27, 2013 02:37 AM|George Qiao|LINK
Thanks for your post.
In your Cart and OrderDetails table, the cartId and detailsId fields are the primary key separately? And they are Identity Column? If yes, please try the below:
insert into OrderDetails(prodId) select prodId from Cart where prodId='xxx'