1. 程式人生 > >mysql按順序生成一個不重復的id

mysql按順序生成一個不重復的id

select str 順序 subst null case sel cas 生成

非字母和非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;

mysql按順序生成一個不重復的id