开发者

MySQL - Ordering all data in alphabetical order but placing a particular item last

Assuming I have the following, data from a field:

开发者_JAVA百科
Category Name
-------------

Games
Movies
All
Music
Software

I want to order the above data in alphabetical (ascending) order but I want 'All' to appear last at the bottom of the list. Not sure how to do this. Thanks.


ORDER BY category_name='All' ASC, category_name ASC


SELECT Category_Name, if(Category_Name='All',1,0) as orderAid
FROM CategoryTable
ODER BY orderAid, Category_Name
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜