Sqlite get max id not working (?)
Actually most simple query to get the max value of a column in sqlite is:
select MAX(id) from table;
You need to add another level of select
for the MAX
, like this:
SELECT *
WHERE id=(SELECT MAX(id) from history)
FROM history;
A better approach would be to order by id
in descending order, and limit the output to a single row:
SELECT *
FROM history
ORDER BY id DESC
LIMIT 1
SELECT top 1 FROM history ORDER BY id DESC