mike55 Posted April 25, 2005 Posted April 25, 2005 Hi all, Am wondering is it possible to do a select statement within an insert statement. insert into Groups (Group_ID, Group_Name, Group_Description, Org_ID) Values ((Select @temp = Max(Group_ID from Groups), @gName,@gDesc,@OrgID) Mike55 Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
HJB417 Posted April 26, 2005 Posted April 26, 2005 Never trying it before, and not knowing what database your using, I'd say yes =D though I'd modify the query insert into Groups (Group_ID, Group_Name, Group_Description, Org_ID) Values ((Select Max(Group_ID) from Groups), @gName,@gDesc,@OrgID) Quote
DocEdge Posted April 26, 2005 Posted April 26, 2005 MS SQL Example The example below works for MS SQL. To include a select statement in an insert you have to create a "derived table". The derived table must match the structure of the table being inserted. I hope this helps. -- Bryant insert Groups select Group_ID , Group_Name, Group_Description, Org_ID from Groups where Group_ID = ( select Max( Group_ID ) from Groups ) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.