Reputation: 2025
I have a table with three columns as follows:
id INTEGER name TEXT value REAL
How can I select the value
at the maximum id
?
Upvotes: 10
Views: 22925
Reputation: 21
Try this:
SELECT value FROM table WHERE id==(SELECT max(id) FROM table));
Upvotes: 1
Reputation: 180240
Get the records with the largest IDs first, then stop after the first record:
SELECT * FROM MyTable ORDER BY id DESC LIMIT 1
Upvotes: 20
Reputation: 1629
Just like the mysql, you can use MAX()
e.g. SELECT MAX(id) AS member_id, name, value FROM YOUR_TABLE_NAME
Upvotes: 6
Reputation: 93511
If you want to know the query syntax :
String query = "SELECT MAX(id) AS max_id FROM mytable";
Upvotes: 0