Save the result from LAST_INSERT_ID( ) after creating a new record in a table that has an AUTO_INCREMENT column to a variable
mysql> SELECT @last_id := LAST_INSERT_ID( );