sql 中如何将返回的记录某一条置顶
将table1中id 为2的记录置顶
select * from table1
order by case when id='2' then 0 else 1 end
例子:将已发布的置顶,status 0:未发布 1:已发布 2:已下架
select ID,NO_DEMAND,NAME_UNIT,WEIGHT_PLAN,TIME_ENABLE,TIME_CREATE,CREATER,COMMENT ,case STATUS when '0' then '未发布' when '1' then '已发布' when '2' then '下架' end as STATUS ,case FEEDBACK when '0' then '未确认接收' when '1' then '已确认接收' when '2' then '已确认不接收' end as FEEDBACK from bus_demand where valid='1'order by case when status='1' then 0 else 1 end