Oracle结果集操作

结果集:通俗的讲,其实就是你通过select语句查找到的数据行的集合
我们可以对结果集进行各种操作,但这个是有前提的,前提是你的结果集查询的字段以及查询的列数是一样的
现有一张学生表用于本节演示,结构以及数据如下:

对结果集的操作可以有如下几种:
union union all minus intersect
union:联合两个结果集,但是会去掉重复的数据
例如:
select a.id,a.name
from student a
where a.id <3
UNION
select b.id,b.name
from student b
where b.id <4
执行结果:

union all:联合两个结果集,但是会保留 重复数据
比如:
select a.id,a.name
from student a
where a.id <3
UNION ALL
select b.id,b.name
from student b
where b.id <4
执行结果:

minus:把两个结果集中相同的数据去掉,返回留下的数据
比如:
select a.id,a.name
from student a
where a.id <3
MINUS
select b.id,b.name
from student b
where b.id <4
执行结果:

intersect:取交集,保留结果集相同的部分
select a.id,a.name
from student a
where a.id <3
INTERSECT
select b.id,b.name
from student b
where b.id <4
执行结果:

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值