【发布时间】:2011-10-28 19:40:07
【问题描述】:
我有如下表格:
table A
id name email
1 test1 ex@ex.com
2 test2 ex@ex.com
3 test3 ex@ex.com
4 test4 ....
5 test5 ....
table B
id catA catB year member
1 false true 2011 2
2 true false 2011 3
3 fals true 2010 5
我想获取表 A 中的每一行并按以下方式对其进行排序:
FIRST, get user 2 (current year, based on table B)
SECOND, get user 3 (current year, based on table B)
after that get users that is in table B
after that get all other users.
我知道我可以有特定的 sql 来获取前两个用户,而只是 休息。但是我不应该能够通过一个很好的 ORDER by statement 来获得它们吗?就像限制一阶语句只影响第一行...
【问题讨论】:
-
如果您的问题有答案,请接受。
标签: mysql sql postgresql sql-order-by