SQLite: Selecting the maximum corresponding value SQLite: Selecting the maximum corresponding value sqlite sqlite

SQLite: Selecting the maximum corresponding value


Get the records with the largest IDs first, then stop after the first record:

SELECT * FROM MyTable ORDER BY id DESC LIMIT 1


Just like the mysql, you can use MAX()

e.g. SELECT MAX(id) AS member_id, name, value FROM YOUR_TABLE_NAME


If you want to know the query syntax :

String query = "SELECT MAX(id) AS max_id FROM mytable";