1、子查询in 、any 、all
select * from emp e where e.emp_dep_id = (select d.dep_id from dep d where d.dep_name='市场部')
--匹配子查询结果的任意一个值
select * from emp e where e.emp_dep_id in (select d.dep_id from dep d where d.dep_name in('市场部','研发部'))
--只要符合子查询的任意一个
select * from emp e where e.emp_dep_id >any (select d.dep_id from dep d where d.dep_name in('市场部','研发部'))
--必须符合子查询的全部
select * from emp e where e.emp_dep_id >all (select d.dep_id from dep d where d.dep_name in('市场部','研发部'))
2、使用exists 和not exists
select e.* from emp e where exists (select 1 from dep d where d.dep_name='市场部' and e.emp_dep_id=d.dep_id)
select e.* from emp e where not exists (select 1 from dep d where d.dep_name='市场部' and e.emp_dep_id=d.dep_id)
分享到:
相关推荐
ORACLE子查询
Oracle 子查询
oracle笔记子查询,有子查询相关的知识点笔记和具体的案例代码!
oracle子查询学习教案.pptx
oracle表连接和子查询实例 所有的实例查询都包含在里面,不会担心笔试oracle子查询。
简单的介绍oracle子查询语句的使用,
oracle子查询PPT课件.ppt
oracle子查询PPT课件.pptx
oracle子查询PPT学习教案.pptx
Oracle子查询优化的最佳实践.pptx
基于成本的ORACLE子查询性能研究.pdf
oracle 数据库的子查询的相关内容,新手可以多看看
一个有关子查询的课件,简单明了,读者可以了解到:描述子查询可以解决的问题类型。 定义子查询。 列出子查询的类型。 写出单行或者多行的子查询。
通过本章学习,您将可以: ...子查询对空值的处理 在 FROM 子句中使用子查询 在SQL中使用单列子查询 相关子查询 书写相关子查询 使用子查询更新和删除数据 使用 EXISTS 和 NOT EXISTS 操作符 使用 WITH 子句
3、超女基本信息表编号(主键)姓名颜值代码(外键)身材代码(外键)身高备注0101西施24170这是一个非常漂亮姑娘,老公是夫差,男朋友是范蠡 4、表之间的关系
复杂相关子查询 动画版
oracle中的子查询使用场合,种类,使用方法,错误排除