Save the result from LAST_INSERT_ID( ) after creating a new record in a table that has an AUTO_INCREMENT column to a variable : LAST_INSERT_ID « Function « SQL / MySQL






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( );

   
    
    
    
    
    
  








Related examples in the same category

1.Each time a conference registration form is received, enter the attendee information into the attendee table.
2.Update with LAST_INSERT_ID
3.Using LAST_INSERT_ID() in insert statement
4.To see what the new seminar records look like, use the LAST_INSERT_ID() value to retrieve them:
5.Use the new value to retrieve the entire record, without even knowing what the id is