我有一個像表:SQL - ORDER BY語句
table A
id name email
1 test1 [email protected]
2 test2 [email protected]
3 test3 [email protected]
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的聲明?像限制一階聲明只是影響第一行...
如果你有問題的答案,請接受它。 –