0

I have an SQL database with two columns "Message" and "Datetime". I want to know when the last entry was added. I want to get the highest datetime value.

What the most efficient way to query the database in Android/Java to get this value?

Christian
  • 25,249
  • 40
  • 134
  • 225

1 Answers1

3

Assuming you have SQLite:

If your column is TEXT or REAL then this will give you newest item:

SELECT * FROM Table ORDER BY date(column) DESC Limit 1

or

SELECT * FROM Table ORDER BY datetime(column) DESC Limit 1

or simply

SELECT * FROM Table ORDER BY column DESC Limit 1
Balkrishna Rawool
  • 1,865
  • 3
  • 21
  • 35