select * from Student order by (case when Age = 18 then 0 else 1 end)
Studetn表中的Age字段,如果Age等于18就排在最前面,其他的排在最后面,查询的结果如下:
name age sex
张三 18 男
李四 18 男
王五 17 男
孙七 19 男
赵六 20 男
结束语:如果有写的不好或者不太懂得地方可以在下方评论
select * from Student order by (case when Age = 18 then 0 else 1 end)
Studetn表中的Age字段,如果Age等于18就排在最前面,其他的排在最后面,查询的结果如下:
name age sex
张三 18 男
李四 18 男
王五 17 男
孙七 19 男
赵六 20 男
结束语:如果有写的不好或者不太懂得地方可以在下方评论
本文标题:Mysql查询按指定字段的指定值进行排序
本文链接:https://www.haomeiwen.com/subject/nanhwhtx.html
网友评论