phant0m Posted June 19, 2010 Share Posted June 19, 2010 Hi I have a parent/child structure and I'd like to be able to insert them all at once. INSERT INTO table (parent_id, description) VALUES (null, parent item), (<expression to refer to the auto_increment value of the previously inserted row>, child item) LAST_INSERT_ID() always return the AUTO_INCREMENT from the last query, so I can't use that. Is there any way to accomplish doing it in one query instead of inserting the parent item in a query, and all the children in a second query? Quote Link to comment https://forums.phpfreaks.com/topic/205250-multi-row-insert-refer-to-first-auto_increment/ Share on other sites More sharing options...
Mchl Posted June 19, 2010 Share Posted June 19, 2010 There isn't. Quote Link to comment https://forums.phpfreaks.com/topic/205250-multi-row-insert-refer-to-first-auto_increment/#findComment-1074345 Share on other sites More sharing options...
phant0m Posted June 19, 2010 Author Share Posted June 19, 2010 ok, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/205250-multi-row-insert-refer-to-first-auto_increment/#findComment-1074386 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.