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.
精彩评论