SQL / Database

How to get the last created auto-increment ID from a MySQL table

If you’re like me then you’re developing like crazy.  Once in a while you may need to retrieve the auto-increment ID value from the last created row you inserted into a particular mysql table.  Yea… when you insert a new row into a mysql table there is no apparent way to just return the ID from the row’s auto-increment field.  So to do this using PHP, simply use the

mysql_insert_id()

functin, which will return the last created ID as an interger.

Syndicate content