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

 

posted @ 2018-04-18 15:15  FH1004322  阅读(1249)  评论(0编辑  收藏  举报