Deprecated: Optional parameter $keys declared before required parameter $cms_id is implicitly treated as a required parameter in /home/www/dev/work/class/blog/CmsKey.php on line 75

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\main::$outlink is deprecated in /home/www/dev/work/website/lvesu/template/blog/cms/cms.tpl on line 2

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\main::$status is deprecated in /home/www/dev/work/website/lvesu/template/blog/index.head.php on line 2
mysql升序将0或者null排到最后 - 互联网笔记

略微加速

略速 - 互联网笔记

mysql升序将0或者null排到最后

2021-12-01 leiting (2687阅读)

标签 MySql

将null排在最后

order by if(isnull(level), 99999, level) asc

将0排在最后

1.Order BY表达式
SELECT nian ,gz from Tbl ORDER BY gz!=0 desc,gz asc
2.算术法
SELECT nian ,gz,1/gz as od from Tbl ORDER BY od desc


北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3