开发者

MYSQL - sort a list, how to always have one result at the end?

开发者 https://www.devze.com 2023-01-03 21:30 出处:网络
I have a table with just as ID and a value. Let\'s say this list have 4 items, such as Apple,Banana, Zuchinni, and Other. I want to sort the list alphabetically, but always have \'Other\' be the last

I have a table with just as ID and a value. Let's say this list have 4 items, such as Apple,Banana, Zuchinni, and Other. I want to sort the list alphabetically, but always have 'Other' be the last option开发者_JAVA技巧. Is there a way to accomplish this using a query?


ORDER BY `column_name` = 'Other', `column_name`


Sort by IIF(item = 'Other', 1, 0) first, or whatever the mysql equivalent is, then your item column.

0

精彩评论

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