条件查询 {where后面的写法}
关系运算符: > < = <= >= != <>
逻辑运算符: and or not
其他运算符: like 模糊查询
in(set) 在某个区间内
between .. and.. 在某个区间内
is not 判断为空
is not null 判断不为空
----查询每月能得到奖金的员工信息
select * from emp;
select * from emp where comm is not null;
----查询工资在1500-3000之间的员工信息
select * from emp where sal between 1500 and 3000;
select * from emp where sal >= 1500 and sal <= 3000;
----查询名字在某个范围内的员工信息('JONES','SCOTT','FORD')
select * emp where ename in ('JONES','SCOTT','FORD');
模糊查询:like
% 匹配多个字符
_匹配单个字符
如果有特殊字符需要使用escape转义
-----查询员工姓名第三个名字是O的员工信息
select * from emp where ename like '__O%';
----查询员工姓名中,包含%的员工信息
update emp set ename = 'TUR%NER' where ename = 'TURNER';
select * from emp where ename like '%\%%' escape '\';
排序:order by
升序:asc ascend
降序:desc descend
排序注意null问题,nulls 默认是first 需要的话可以改为last
如果同时排列多列,,中间用,隔开
----查询员工信息,按照奖金由高到低排序
select * from emp order by comm desc nulls last;
----查询部门编号和工资,按照部门升序排序,工资降序排序
select deptno,sal from emp order by deptno asc, sal desc;