Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select last row

Please how can I retrieve the last on an Android DB? I'm using the Sugar ORM library to abstract all db operation but I can't seem to be able to figure out how to retrieve the oldest record on the db.

like image 615
Mr Smith Avatar asked Dec 12 '22 03:12

Mr Smith


1 Answers

You have to order by some timestamp, if you have it, or by the ID, if it is autoincrementing, and take only the first result:

Thing.find(Thing.class, null, null, null, "timestamp DESC", "1");
like image 149
CL. Avatar answered Dec 13 '22 15:12

CL.