【发布时间】:2012-07-10 23:52:01
【问题描述】:
我有一张表,我希望在一个查询中使用几个不同的条件/优先级对它进行排序。
例如,一个名为“用户”的表有 5 列:
userID
userName
age
gender
birthday
在年龄、性别、生日可能为null的情况下,希望查询返回表行的优先顺序为:
1. Age, gender and birthday is not null,
2. Age, gender is not null,
3. Age is not null,
4. Then the rest of the rows
我查看了 UNION、UNION ALL 和 ORDER BY IF,但没有得到结果(可能我查询错误)。
希望有人可以帮助我解决这个问题。谢谢。
【问题讨论】:
-
您使用的是 MySQL、Oracle、SQL Server 等吗?
标签: sql phpmyadmin