vikaspa Posted April 4, 2008 Share Posted April 4, 2008 Dear Please help me I am inserting a records in a table I want to know the id for the row inserted which is auto generated How can i get it Please please help Quote Link to comment Share on other sites More sharing options...
zenag Posted April 4, 2008 Share Posted April 4, 2008 $sql=mysql_query("insert into ....); echo mysql_insert_id(); gives the id of the row inserted. Quote Link to comment Share on other sites More sharing options...
jana Posted April 4, 2008 Share Posted April 4, 2008 as a mysql query u can use select last_insert_id(); as in php u can u as zenag said Quote Link to comment Share on other sites More sharing options...
gluck Posted April 4, 2008 Share Posted April 4, 2008 as a mysql query u can use select last_insert_id(); as in php u can u as zenag said Make sure you get id right after the insert else if someone else fires an insert before you did the select you might get wrong results. 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.