Buyocat Posted September 16, 2006 Share Posted September 16, 2006 Hi I have two tables in a parent - child relationship and I'd like to be able to insert to them both with a single query. If that isn't possible please just say so, if it is possible let me know! Here are what my tables look like...parent tableidtitledate_addedstatuschild tableparent_idsome_other_dataI want to be able to insert the data into the parent and then take the unique key id from that and place it into the child table along with any other data. I can see how this can be done in two queries, however it seems like two queries is a lot, especially considering this is a frequently run insert. So, is there any way to somehow get the inserted rows id from the parent table and push it into the child table all in one step? Quote Link to comment Share on other sites More sharing options...
fenway Posted September 16, 2006 Share Posted September 16, 2006 Can't do that... one insert per table, then just grab the LAST_INSERT_ID(). Quote Link to comment Share on other sites More sharing options...
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.