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 <>'張三'
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 <>'張三'
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。