开发者

MySQL get latest X rows, while ordering by column?

开发者 https://www.devze.com 2023-02-11 05:12 出处:网络
I need to get the latest X rows.So I do something like SELECT * FROM `item` ORDER BY `date` DES开发者_JS百科C LIMIT X

I need to get the latest X rows. So I do something like

SELECT * FROM `item` ORDER BY `date` DES开发者_JS百科C LIMIT X

But I want to items to be returned ordered by column Y, where Y!=date

How can this be done?


Subselect

SELECT * FROM
(SELECT * FROM `item` ORDER BY `date` DESC LIMIT X)
ORDER BY Y
0

精彩评论

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