我在下面的sql中,想要創建多個ORDER BY。mysql按多個條件排序
SELECT
r.*,
s.uzunluq,
b.id,
au.status_id as aksessuar_status,
au.aksessuar_id,
au.aksessuar
FROM
seksiya s,
result r
LEFT JOIN bosh_seksiya_aksessuar b
ON
b.bosh_seksiya = r.model AND
b.ERK = :ses
LEFT JOIN aksessuar_up au
ON au.model_id = r.res_id AND
au.user_id = :user_id AND
au.status_id = 9
WHERE
r.user_id = :user_id AND
r.model=s.seksiya AND
s.erk = :ses AND
r.status_id IN (1,2,3,4,5)
ORDER BY
r.res_id
我認爲寫的PDO PDO對你來說並不重要,大家,導致我的問題只關於這個SQL。這個SQL的工作非常好,我只是想添加額外的功能。所以,尋找此列:r.status_id IN (1,2,3,4,5)
我已經給Order BY r.res_id
我的問題: 我想用多個訂單每個status_id
如何訂購:
ORDER BY r.res_id DESC WHERE r.status_id IN (1,2)
AND
ORDER BY r.res_id WHERE r.status_id IN (3,4,5)
在這個SQL?
也許你會更好做一個'聯盟' – Mike