SQLite: What is the ID of the last inserted row?
Info by SmartUser | 2013-11-07 at 20:21
Question: We have added a new row into a SQLite database using an INSERT statement. Now we need the ID of the last inserted row to use it in another statement or to store it somewhere else.
Solution: SQLite is providing the function last_insert_rowid() returning the ID of the last inserted row. Here is an example:
SELECT last_insert_rowid() FROM tab
Suppose our table is named "tab" and we have just added a new entry into this table. In this case, the request from above provides us the ID of this last entry.
About the Author
The author has not added a profile short description yet.
Show Profile
Related Topics
MySQL: Rename Name of a Database
Tip | 1 Comment
MySQL/PHP: How to retrieve the last INSERT ID
Info | 0 Comments
MySQL: Write current Date or Time into Column
Tutorial | 0 Comments
How to Replace multiple Texts at the same Time
Tutorial | 0 Comments
How to resize Image before Upload in Browser
Tutorial | 13 Comments
SQLite: Creating an Index on one or more Columns
Info | 0 Comments
MySQL: Add new Column to a Table
Tutorial | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.