Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fetch the last record of a table using room data base

I want to get the value of a column and the value must be the last record of a table, I ve searched in online and I didnt get one using Room database can any one help me to get the query for that.
this is my table constructor

public ItemTable(String itemid, String itemname, String itemdesc, String imageurl, String price, String timestamp) {
        this.itemid = itemid;
        this.itemname = itemname;
        this.itemdesc = itemdesc;
        this.imageurl = imageurl;
        this.price = price;
        this.timestamp = timestamp;
    }

I want timestamp of last inserted record, how can I get it? what is the query to achieve that

like image 931
Padmaja Rani Avatar asked Dec 06 '22 09:12

Padmaja Rani


1 Answers

you can use this query.

SELECT * FROM ItemTable ORDER BY timestamp DESC LIMIT 1
like image 52
Bhanu Prakash Pasupula Avatar answered Mar 05 '23 16:03

Bhanu Prakash Pasupula