Oracle中的Exists、In、ANY、ALL
Oracle in all exists any
2023-09-14 09:02:14 时间
Exists:子查询至少返回一行时条件为true。
Not Exists:子查询不返回任何一行时条件为true。
In:与子查询返回结果集中某个值相等。
Not In:与子查询返回结果集中任何一个值不相等。
ANY:比子查询返回结果中的某个值大。
=ANY:与子查询返回结果中的某个值相等。
ANY:比子查询返回结果中的某个值小。
ALL:比子查询返回结果中的所有值都大。
ALL :比子查询返回结果中的所有值都小。
1、查询与10号部门某个员工工资相等的员工信息。
select empno ,ename,sal from emp where sal in(select sal from emp where deptno=10)
下面这句话与上的语句效果一样
select empno ,ename,sal from emp where sal=any(select sal from emp where deptno=10)
效果如下图:
小注:
=any()括号中即使出现重复的值,也不会报错,比如:
select empno ,ename,sal from emp where sal=any(2450.00,5000.00,5000.00)2、查询比10号部门某个员工工资高的员工信息。
select empno ,ename,sal from emp where sal any(select sal from emp where deptno=10)
在emp表中工资的最小值为1300,下面这句话与上面语句的效果一样
select empno ,ename,sal from emp where sal 1300
效果如下图:
3、查询比10号部门所有员工工资高的员工信息。
select empno ,ename,sal from emp where sal all(select sal from emp where deptno=10)
效果如下图(没有查询到数据):
相关文章
- 【oracle】更新大批量数据变更步骤
- oracle基本笔记整理及案例分析1
- 项目中使用oracle序列
- Oracle 中 decode 函数用法
- 使用Perl管理Oracle数据库
- How to use udev for Oracle ASM in Oracle Linux 6 怎样使用udev在linux 6系统上使用asm
- oracle针对oracle和grid用户---环境变量设置---单实例和RAC
- Windows DOS窗体下Oracle 数据库的导入导出命令
- Do not use LOB in Oracle(OLTP) -- record an optimization experience
- oracle面试题
- Oracle不带传出参数的存储过程创建及调用
- oracle 判断某个表是否存在
- Oracle中SQL的性能优化
- Oracle中的Exists、In、ANY、ALL
- oracle 查询本周,本月,本年数据
- Oracle与Sql Server复制表结构及数据
- Oracle中的Exists、In、ANY、ALL
- Oracle - ORA-12505, TNS:listener does not currently know of SID given in connect descriptor 解决
- PostgreSQL的学习心得和知识总结(一百二十一)|词法级自上而下完美实现Oracle数据库PL/SQL过程语言的 for in list 的实现方案
- How to Install Oracle 12.2.0.1 Database software in silent mode
- How To Enable Archive Log Mode In Oracle Database 19c