Reputation: 525
I wanted to get last row from database. I have come to realize there is only rawQuery on the documentation.
db.rawQuery("SELECT * FROM $tableName WHERE id=?', []");
So how do i manipulate the above query to fetch last row by id?
Upvotes: 1
Views: 1833
Reputation: 41
Try something like this, assuming you have self-incrementing field:
db.rawQuery("SELECT * FROM $tableName WHERE id=(SELECT max(id) FROM $tableName, []" );
Upvotes: 3