开发者

MySQL - ordering alphabetically except for one entry?

开发者 https://www.devze.com 2023-01-05 14:19 出处:网络
I have to sort a list of categories using MySQL as I am using a CMS that only allows this. Is there a way to sort alphabetically but to return one entry (\"Other\") at the 开发者_开发技巧end of the li

I have to sort a list of categories using MySQL as I am using a CMS that only allows this. Is there a way to sort alphabetically but to return one entry ("Other") at the 开发者_开发技巧end of the list?


ORDER BY ColumnName = 'Other', ColumnName


if 'Other' is not present in Table USE

(SELECT name FROM categories ORDER BY name)
UNION
(SELECT "Other")
0

精彩评论

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