Categories
Linux MySQL PHP

MySQL: get value of last auto-increment field

If you use an auto increment field (autonumbering) in your database table, you can find the last generated number by performing the following query :

select last_insert_id();

This will get the last id for the current connection. If you close the connection you can’t get the number again, and it will only return the last number for *your* connection. It is kept on a per-connection basis.

Leave a Reply

Your email address will not be published. Required fields are marked *