Curriculum
Course: MYSQL
Login

Curriculum

MYSQL

MySQL References

0/140
Text lesson

LAST_INSERT_ID

Example

Return the ID generated for the last row inserted into a table with an AUTO_INCREMENT column.

SELECT LAST_INSERT_ID();

Definition and Usage

The LAST_INSERT_ID() function retrieves the AUTO_INCREMENT ID of the last inserted row in a table.

Syntax

LAST_INSERT_ID(expression)

Parameter Values

Parameter

Description

expression

Not required; an expression

Technical Details

Works in:

 From MySQL version 4.0