开发者

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

开发者 https://www.devze.com 2023-01-06 03:49 出处:网络
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 3SELECT *

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

精彩评论

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