欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

MySQL 综合案例1

程序员文章站 2022-07-04 18:50:08
...

综合案例1

找出工资在1250到3000之间的员工信息,要求按照薪资降序排列:

mysql> select ename, sal from emp where sal between 1250 and 3000 order by sal desc;
+--------+---------+
| ename  | sal     |
+--------+---------+
| SCOTT  | 3000.00 |
| FORD   | 3000.00 |
| JONES  | 2975.00 |
| BLAKE  | 2850.00 |
| CLARK  | 2450.00 |
| ALLEN  | 1600.00 |
| TURNER | 1500.00 |
| MILLER | 1300.00 |
| WARD   | 1250.00 |
| MARTIN | 1250.00 |
+--------+---------+
10 rows in set (0.00 sec)

关键字顺序不能变:

select 
	...
from 
	...
where
	...
order by	# (排序总是在最后执行!)
	...