dan400007 Posted November 16, 2006 Share Posted November 16, 2006 Hi, I want to insert a record into a mysql table and then have it return ID for the record just entered. Example of what I want to happen is below:table:ID mediumint( 8 ) Auto-increment unsigned not nullcol1 textcol2 textINSERT INTO table (col1, col2) VALUES ('This is col1', 'This is col2');When the insert occurs I want mysql to return the ID for the record it just inserted, is this possible?Thanks, Dan Quote Link to comment Share on other sites More sharing options...
trq Posted November 16, 2006 Share Posted November 16, 2006 Funnilly enough there is a function made especially for that. [url=http://php.net/mysql_insert_id]mysql_insert_id[/url]. Quote Link to comment Share on other sites More sharing options...
dan400007 Posted November 16, 2006 Author Share Posted November 16, 2006 Brilliant!! :DThanks for such a quick reply.Dan. 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.