Oracle基本函数查询
查询行(记录)
where 过滤行记录条件 ,条件有
a)、= 、 >、 <、 >=、 <=、 !=、 <>、 between and
b)、and 、or、 not、 union、 union all、
intersect 、minus
c)、null :is null、 is not null、 not is
null
d)、like :模糊查询 % _ escape('单个字符')
f)、in 、 exists(难点) 及子查询
比较条件
= 、>、 <、 >=、 <=、 !=、 <>**
select * from emp where deptno !=20;
select * from emp where deptno <>20;
select * from emp where sal between 800 and
950; --between and是成对出现的
--查询 员工的年薪大于20000的 员工名称、岗位 年薪
--1)、nvl
select ename,job,12*(nvl(comm,0)+sal) income
from emp;
--2)、年薪大于20000
--错误不能使用别名: select ename,job,12*
(nvl(comm,0)+sal) income from emp where
income>2000;
--a)、嵌套一个: 查询在前 过滤在后
select ename,job,income from
(select ename,job,12*(nvl(comm,0)+sal) income
from emp) where income>2000;
--b)、不使用别名 (推荐) :过滤在前,查询在后
select ename,job,12*(nvl(comm,0)+sal) income
from emp where 12*(nvl(comm,0)+sal) >2000 ;
--了解 any some all
-- >=any(值列表) 大于最小值<=any(值列表)小于最大
值
select * from emp where sal >=any(900,2000);
select * from emp where sal <=any(900,2000);
-- some与any 一样的效果
-- all 大于最大值 小于最小值
s