Jump to content

[SOLVED] Getting auto_increment value of latest INSERT


eludlow

Recommended Posts

If I insert a row that has an auto_increment value (use it as row id field..) but then I want to use that id value immediately after the insert is complete (I am sending a mail containing, amongst other things, the latest id), what is the best way of getting the latest value?

 

So for instance I have:

 

mysql_query("INSERT INTO `table` VALUES ('', 'field two')");

 

And the first field in the above is the auto_increment field.  I obviosuly don't know what the value of that is to now SELECT the row in question.

 

Hope this makes sense!

 

Many thanks,

Ed Ludlow

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.