开发者

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

开发者 https://www.devze.com 2023-03-31 15:10 出处:网络
Assuming I have the following, data from a field: 开发者_JAVA百科 Category Name ------------- Games Movies

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

精彩评论

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

关注公众号