Syntax
LAST_INSERT_ID()
Purpose
LAST_INSERT_ID() returns the value of the last inserted auto-increment field in the current session.
If the last INSERT statement inserts multiple rows, LAST_INSERT_ID() returns the auto-increment field value of the first inserted row.
Examples
obclient> CREATE TABLE t1(c1 INT, c2 INT AUTO_INCREMENT);
obclient> SELECT LAST_INSERT_ID();
+------------------+
| LAST_INSERT_ID() |
+------------------+
| 0 |
+------------------+
1 row in set