mariaDB 5.5.68-MariaDB(Centos)中sql语句可以正常运行sql
SELECT CONCAT('ORDER-',(COALESCE ( MAX( SUBSTR( order_no, 7, LENGTH( order_no ))), CONVERT ( DATE_FORMAT( NOW(), '%Y%m%d' ), INT )* 1000 )) + 1) FROM orders WHERE order_no LIKE CONCAT('ORDER-',DATE_FORMAT( NOW(), '%Y%m%d' ),'%') order by order_no
mysql5.7.23中需要把convert函数中的 INT改成UNSIGNED
SELECT CONCAT('ORDER-',(COALESCE ( MAX( SUBSTR( order_no, 7, LENGTH( order_no ))), CONVERT ( DATE_FORMAT( NOW(), '%Y%m%d' ), UNSIGNED )* 1000 )) + 1) FROM orders WHERE order_no LIKE CONCAT('ORDER-',DATE_FORMAT( NOW(), '%Y%m%d' ),'%') order by order_no
猜测可能与sql规范有关,没深究