如何在条件中对Mysql中的行进行排序?

时间:2014-12-03 22:13:42

标签: mysql sql

如果需要ORDER BY FIELD_id DESC,,如何在Mysql中执行订单,但第一行必须是FIELD_id = 5

2 个答案:

答案 0 :(得分:4)

您可以使用条件排序:

ORDER BY Field_id = 5 DESC, field_id DESC

SQL Fiddle Demo

答案 1 :(得分:0)

你应该从申请中做到,或者你可以做联合

SELECT field_id, ... FROM table WHERE field_id = 5

UNION

SELECT field_id, ... FROM table WHERE field_id != 5 ORDER BY field_id