code:<pre style="font-size:x-small; font-family: monospace;">CREATE TABLE animals (grp ENUM(´fish´,´mammal´,´bird´) NOT NULL,
id MEDIUMINT NOT NULL AUTO_INCREMENT
PRIMARY KEY (grp,id));
INSERT INTO animals (grp,name) VALUES("mammal","dog"),("mammal","cat"),("bird","penguin"),("fish","lax"),("mammal","whale");
SELECT * FROM animals ORDER BY grp,id;
Which returns:
+--------+----+---------+
| grp | id | name |
+--------+----+---------+
| fish | 1 | lax |
| mammal | 1 | dog |
| mammal | 2 | cat |
| mammal | 3 | whale |
| bird | 1 | penguin |
+--------+----+---------+</pre>