Syntax
LAST_INSERT_ID()
Purpose
Returns the value of the auto-increment column for the last inserted row in the current session.
Specifically, if the most recent INSERT statement inserted multiple rows, LAST_INSERT_ID() returns the value of the auto-increment column for 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
