bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

MySQL LAST_INSERT_ID() Function

Example

SELECT LAST_INSERT_ID();

Definition and Usage

The LAST_INSERT_ID() function returns the AUTO_INCREMENT id of the last row that has been inserted in a table.

Syntax

LAST_INSERT_ID(
expression
)

Parameter Values

ParameterDescription
expressionOptional. An expression

Technical Details

Works in:From MySQL 4.0

Previous

MySQL ISNULL() Function

Next

MySQL NULLIF() Function