mysql-DQL查询语句-条件查询where-between..and
一、between....and....两个值之间,闭区间,遵循从小到大原则;在where条件之后
- 案例:查询工资在在2450和3000之间的员工信息:包含两个工资范围:
- select empno,ename,sal
- from emp
- where sal between 2450 and 3000;
二、条件查询where:select 字段1,字段2 from 表名 where 条件;
- 1、=等于 :查询薪资等于800的员工姓名和编号: select empno,ename from emp where sal =800;
- 2、 <>或 !=不等于: select empno,ename from emp where sal <>800;
- 3、<小于: select empno,ename from emp where sal <2000;
- 4、<=小于等于:select empno,ename,sal from emp where sal <=3000;
- 5、 >大于: 查询薪资大于三千的员工姓名和编号:select empno,ename,sal from emp emp where sal>3000;
- 6、 >=大于等于: 查询薪资大于等于三千的员工姓名和编号:select empno,ename,sal from emp where sal >=3000;
- 7、>=and<=:查询薪资在2450和3000之间的员工信息:包含两个工资范围:
- select empno,ename,sal from emp where sal >=2450 and sal <=3000;