SET @last_id = LAST_INSERT_ID() code example Example: mysql set last_insert_id SET @last_id = LAST_INSERT_ID();