MYSQL显示最新的几行,但以升序显示结果

时间:2011-06-30 02:20:00

标签: mysql

我正在使用此查询

SELECT * FROM notes ORDER BY id DESC LIMIT 3

显示最新的三个音符显示如下: 注24,注23,注22

我要做的是显示结果如下: 注22,注23,注24。 任何想法?

2 个答案:

答案 0 :(得分:2)

重新选择结果行重新排序,但这次使用ASC顺序(默认值):

SELECT * 
FROM (SELECT * FROM notes ORDER BY id DESC LIMIT 3) x
ORDER BY id

答案 1 :(得分:1)

你可以尝试

SELECT * FROM (SELECT * FROM notes ORDER BY id DESC LIMIT 3)
AS t ORDER BY t.id ASC;