Fluoresce Posted March 24, 2009 Share Posted March 24, 2009 When I insert data into my table, an ID is automatically generated for the new row through auto-incrementation. That's the only thing that is unique to each row. I need to select some of the new data immediately, but I obviously don't know its ID. My question therefore is, is it possible to insert data and select its ID at the same time? Quote Link to comment https://forums.phpfreaks.com/topic/150835-solved-can-you-select-the-auto-incremented-id-of-what-youve-just-inserted/ Share on other sites More sharing options...
Festy Posted March 24, 2009 Share Posted March 24, 2009 Yes it is possible. Use mysql_insert_id() to fetch the recently inserted id. Quote Link to comment https://forums.phpfreaks.com/topic/150835-solved-can-you-select-the-auto-incremented-id-of-what-youve-just-inserted/#findComment-792377 Share on other sites More sharing options...
Fluoresce Posted March 24, 2009 Author Share Posted March 24, 2009 Thanks, Festy! mysql_insert_id() works beautifully. Quote Link to comment https://forums.phpfreaks.com/topic/150835-solved-can-you-select-the-auto-incremented-id-of-what-youve-just-inserted/#findComment-792391 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.