SQLite LAST_INSERT_ROWID() Function
Example
Insert a shipper, and return its ShipperID:
INSERT INTO Shippers (ShipperName)
VALUES ('Fast Bikes');
SELECT LAST_INSERT_ROWID();
Try it Yourself »
Definition and Usage
The LAST_INSERT_ROWID() function returns the rowid of the last row that was inserted in the same connection. For a table with an INTEGER PRIMARY KEY, it is the id of the new row.
Note: The RETURNING clause is another way to get the id of a new row.
Syntax
LAST_INSERT_ROWID()
Technical Details
| Return type: | Integer |
|---|