I use sqlite.
Rows are continuously added to the database (using code). I need to get the last line written there.
How to do it?
Record date is.
I use sqlite.
Rows are continuously added to the database (using code). I need to get the last line written there.
How to do it?
Record date is.
Reply from comments from Alexey Shimansky
SELECT * FROM tbl ORDER BY created_at DESC LIMIT 1
Execute SELECT last_insert_rowid()
query SELECT last_insert_rowid()
to DB. The result will be a record containing the last ID added.
If autoincrement primary key
then you can use this query select seq from sqlite_sequence where name="table_name"
. It returns the current value of the increment, which will be the key to the last added record.
last_insert_rowid()
returns the last id added in this session . In another session that did not insert, this function would not do anything. - MikeSource: https://ru.stackoverflow.com/questions/489410/
All Articles
SELECT smth FROM table ORDER BY column DESC LIMIT 1
- Alexey Shimansky