例子:
mysql> create table employee(num int(3), d_id int(5), name varchar(20), age 3), sex varchar(5), homeaddr varchar(30)); // 可以看到首先按照d_id进行升序排列,排列好了之后, // 若d_id字段中有相同的,则按照age进行降序排列。 // 即两种排序在一起的话,是有先后顺序的。 mysql> select * from employee order by d_id asc, age asc; +------+------+-------+------+-------+----------+ | num | d_id | name | age | sex | homeaddr | +------+------+-------+------+-------+----------+ | 5 | 1001 | robot | 20 | man | zhuhai | | 2 | 1001 | mike | 25 | man | nanjing | | 1 | 1001 | jack | 26 | man | beijing | | 3 | 1003 | alex | 24 | man | nanchang | | 4 | 1004 | rose | 14 | woman | england | +------+------+-------+------+-------+----------+ 5 rows in set (0.00 sec) mysql>