开发者

MySQL get latest X rows, while ordering by column?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜