[SQL] 让特定的数据 排在最前

Posted JusTang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[SQL] 让特定的数据 排在最前相关的知识,希望对你有一定的参考价值。

mysql目前常用的两种方法,如下:

 

让值为"张三" 的数据排在最前.

-- 方法一
select * from tableName  ORDER BY  case when columnName=张三 then 0  else 1 end  asc


-- 方法二
select * from tableName  where columnName =张三 union all select * from tableName  where columnName <>张三

 

以上是关于[SQL] 让特定的数据 排在最前的主要内容,如果未能解决你的问题,请参考以下文章