You can retrieve the most recent AUTO_INCREMENT value with the LAST_INSERT_ID().
LAST_INSERT_ID() is connection-specific.
mysql> mysql> mysql> CREATE TABLE employee ( -> id MEDIUMINT NOT NULL AUTO_INCREMENT, -> name CHAR(30) NOT NULL, -> PRIMARY KEY (id) -> ); Query OK, 0 rows affected (0.05 sec)
mysql> mysql> desc employee; +-------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+----------------+ | id | mediumint(9) | NO | PRI | NULL | auto_increment | | name | char(30) | NO | | | | +-------+--------------+------+-----+---------+----------------+ 2 rows in set (0.01 sec)