【】原帖地址: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博客 ” ,链接:http://blog.itpub.net/25267658/viewspace-689502/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/25267658/viewspace-689502/
本文介绍了一个关于动物的数据表创建方法及数据插入过程,并展示了如何通过SQL命令进行有序的数据检索。

2069

被折叠的 条评论
为什么被折叠?



