MySQL 排序时如何把0放最后, 其它按照从小到大排序

 

1 SELECT * FROM banner ORDER BY CASE when sort<>0 then sort else 99999 end asc;
2 SELECT * FROM banner ORDER BY CASE when sort<>0 then sort else 99999 end desc;
3 
4 SELECT * FROM banner ORDER BY sort = 0,sort asc;
5 SELECT * FROM banner ORDER BY sort = 0,sort desc;
6 
7 上面两种方法都可以的

 

posted @ 2021-08-06 14:58  赵瑛  阅读(293)  评论(0编辑  收藏  举报

版权所有 © 2022 沅来是澧

如果有程序开发、网站建设等需求的请联系我,QQ:47419233