开发者

How to select the last three rows of a table in ascending order?

I want to select the last three rows of a table in ascending order. What is the query fo开发者_运维百科r that?


SELECT * FROM table ORDER BY DESC LIMIT 3


SELECT * 
FROM ( 
        SELECT * 
        FROM tblname
        ORDER BY rowid DESC
     ) WHERE rownum < 4; 

Rowid is the physical address of every row.
Rownum is the psuedo column which is used to generate sequence number of rows.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜