mysql的顺序是,先是null,然后是DESC
如何按字段sortingDESC,但首先列出NULL值?
所以我有一张桌子:
reuestId | offerId | offerTitle 1 | 1 | Alfa NULL | 2 | Beta 2 | 3 | Gamma
我想select他们,结果是:
NULL | 2 | Beta 2 | 3 | Gamma 1 | 1 | Alfa
尝试这个:
ORDER BY [reuestId] IS NULL DESC, [reuestId] DESC
应该工作(对于mySql)
SELECT * FROM TableX ORDER BY (requestId IS NOT NULL) , requestId DESC