创建一个具有普通数字auto_increment ID的表,但要么用它定义,要么在选择时ZEROFILL使用LPAD添加零。然后CONCAT是值以获得您的预期行为。示例#1:create table so ( id int(3) unsigned zerofill not null auto_increment primary key, name varchar(30) not null);insert into so set name = 'John';insert into so set name = 'Mark';select concat('LHPL', id) as id, name from so;+---------+------+| id | name |+---------+------+| LHPL001 | John || LHPL002 | Mark |+---------+------+示例#2:create table so ( id int unsigned not null auto_increment primary key, name varchar(30) not null);insert into so set name = 'John';insert into so set name = 'Mark';select concat('LHPL', LPAD(id, 3, 0)) as id, name from so;+---------+------+| id | name |+---------+------+| LHPL001 | John || LHPL002 | Mark |+---------+------+