您的位置:首页 > 数据库 > Oracle

Oracle——集合运算

2015-09-17 16:51 465 查看

Oracle——集合运算

union 并集 : 去重并集 : 返回两个集合去掉相同部分的所有记录

union all : 不去重并集 : 返回两个集合所有记录包括相同部分

intersect : 交集 : 返回两个集合相交的部分

minus : 差集 : 返回第一个集合,但不属于第二个集合的记录
---实例:union : 查询a表中10号部门和20部门的信息
select * from table_a where a_id =10
union
select * from table_a where a_id =20

---实例:union all:查询部门信息
select * from table_a
union all
select * from talbe_a

---实例:intersect: 查询部门的信息
select * from table_a
intersect
select * from table_b

---实例:minus:查询对应信息 当前信息的部门编号 存在于部门表中 但是不存在与员工表
select   DEPARTMENT_ID  from   DEPARTMENTS
minus
select   DEPARTMENT_ID  from   EMPLOYEES
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: