【】原帖地址:http://www.itpub.net/viewthread.php?tid=1406840&pid=17397883&page=1&extra=page%3D1#pid17397883
create table animals(
grp enum('fish', 'mammal', 'bird') not null,
id int not null auto_increment,
name char(30) not null,
primary key (grp, id)
)engine=myisam;
insert into animals (grp, name)values
('mammal','dog'),('mammal','cat'),
('bird','penguin'),('fish','lax'),('mammal','whale'),
('bird','ostrich');
select * from animals order by grp asc,id asc;
-- 结果如下:
'fish', '1', 'lax'
'mammal', '1', 'dog'
'mammal', '2', 'cat'
'mammal', '3', 'whale'
'bird', '1', 'penguin'
'bird', '2', 'ostrich'
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25267658/viewspace-689502/ ,如需转载,请注明出处,否则将追究法律责任。