8000 | fmale | +----------+---------+---------+ 2 rows in set (0.00 sec)
2.6.3 查询结果排序
用ORDER BY语句对emp表中所有员工工资高低顺序查询结果(默认是从低到高——升序) mysql> select * from emp order by emp_sal;
查询结果显示如下: +--------+----------+---------+---------+------------+---------+ | emp_id | emp_name | emp_age | emp_sal | emp_bir | emp_sex | +--------+----------+---------+---------+------------+---------+ | 100005 | 啸天 | 27 | 4000 | 1979-07-10 | male | | 100002 | 丽鹃 | 27 | 8000 | 1979-12-31 | fmale | | 100001 | 红枫 | 29 | 9000 | 1977-01-01 | male | +--------+----------+---------+---------+------------+---------+ 3 rows in set (0.00 sec)
用DESC关键字来进行从高到低排序——降序 mysql> select * from emp order by emp_sal desc;
查询结果显示如下: +--------+----------+---------+---------+------------+---------+ | emp_id | emp_name | emp_age | emp_sal | emp_bir | emp_sex | +--------+----------+---------+---------+------------+---------+ | 100001 | 红枫 | 29 | 9000 | 1977-01-01 | male | | 100002 | 丽鹃 | 27 | 8000 | 1979-12-31 | fmale | | 100005 | 啸天 | 27 | 4000 | 1979-07-10 | male | +--------+----------+---------+---------+------------+---------+ &n |