Tuesday, November 21, 2006

How to get last inserted auto increment value using MySQL?

mysql>Select LAST_INSERT_ID();

The LAST_INSERT_ID() is unique to the login session. This can be used to update foreign keys.

If your session didn't update any records, LAST_INSERT_ID() will be zero.

No comments: