mysql 实现序号化数字中 缺失的数字
Posted IT的鱼
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql 实现序号化数字中 缺失的数字相关的知识,希望对你有一定的参考价值。
SELECT
( SELECT IFNULL(max(CAST( commodity_number AS SIGNED )),0) + 1 FROM ( SELECT commodity_number FROM sys_commodity WHERE company_id = '950872849940217856' ) AS b WHERE commodity_number < a.commodity_number ) AS sort
FROM
( SELECT commodity_number FROM sys_commodity WHERE company_id = '950872849940217856' ) AS a
WHERE
a.commodity_number > ( SELECT IFNULL(max(CAST( commodity_number AS SIGNED )),0)+ 1 FROM ( SELECT commodity_number FROM sys_commodity WHERE company_id = '950872849940217856' ) AS b WHERE commodity_number < a.commodity_number )
ORDER BY
commodity_number ASC;
以上是关于mysql 实现序号化数字中 缺失的数字的主要内容,如果未能解决你的问题,请参考以下文章