MySQL 生成自增流水号


#以下是每次执行都初始化变量伪自增序列从0开始,不是从1开始自增
SELECT @rownum:=0 #以chinapostlocalregistry表增加流水号为例。 #insert into chinapostlocalregistry(number,Type,IsUsed,Created,UsedDate) select CONCAT('LAODD',DATE_FORMAT(now(),'%Y%m%d'),LPAD(@rownum:=@rownum+1,4,'0')),21,0,now(),NULL from chinapostlocalregistry
原文地址:https://www.cnblogs.com/FH-cnblogs/p/8875035.html