我们在MySQL中有这样的表:id – int; title – varchar;高清 – tinyint;来源 – tinyint;活跃的 – tinyint;
1. hd >= 3 AND source <> 5
2. hd >= 3 AND source = 5
3. hd = 2
4. other,i.e. hd < 2
请告诉我如何正确地执行它和一个SQL查询?
谢谢.
最佳答案
select * from your_table
order by case when hd >= 3 AND source <> 5 then 1
when hd >= 3 AND source = 5 then 2
when hd = 2 then 3
else 4
end