mysql按顺序生成一个不重复的id

非字母和非0开头按顺序生成一个不重复的id

select case when max(id) is null then '10000001' else max(id)+1 end as id from student;

字母开头按顺序生成一个不重复的id

select case when max(id) is null then 'S10000001' else CONCAT('S',SUBSTRING(max(id),2)+1) end as id from student;

猜你喜欢

转载自blog.51cto.com/1197822/2157676
今日推荐