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
SQLite: IF(a, b, c) Syntax not working
Question | 1 Answer
SQLite: How many rows were affected by an UPDATE or DELETE?
Info | 0 Comments
SQLite: Search for unequal Value
Question | 1 Answer
SQLite: Creating an Index on one or more Columns
Info | 0 Comments
SQLite: Reset AUTOINCREMENT
Question | 1 Answer
SQLite: Check or search for empty values
Question | 1 Answer
SQLite: Check whether table exists
Info | 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.