MYSQL show latest few rows, but display the results in an ascending order
I'm using this query
SELECT * FROM notes ORDER BY id DESC LIMIT 3
I开发者_如何学Got shows the latest three notes displayed as follow: Note 24, Note 23, Note 22
What I'm trying to do is to display the results as follow: Note 22, Note 23, Note 24. Any Ideas ?
Reorder the resulting rows by re-selecting them, but this time use ASC
order (the default):
SELECT *
FROM (SELECT * FROM notes ORDER BY id DESC LIMIT 3) x
ORDER BY id
You can try
SELECT * FROM (SELECT * FROM notes ORDER BY id DESC LIMIT 3)
AS t ORDER BY t.id ASC;
精彩评论