select case when max(id) is null then ‘10000001‘ else max(id)+1 end as id from student;
select case when max(id) is null then ‘S10000001‘ else CONCAT(‘S‘,SUBSTRING(max(id),2)+1) end as id from student;
mysql按顺序生成一个不重复的id
原文:http://blog.51cto.com/1197822/2157676