当前位置:Gxlcms > 数据库问题 > oracle --union和union all

oracle --union和union all

时间:2021-07-01 10:21:17 帮助过:65人阅读

Intersect:对两个结果集进行交集操作,不包括重复行。默认规则排序

例如:对t_user表和t_fchs表求交集

select
*
from
(select
tu.user_name as name,tu.telephone
from
t_user tu)
Intersect
(select
tf.fchs_name,tf.fchs_telephone
from
t_fchs tf)

结果如下:

技术分享

备注:由两张表可知,交集的结果就只有这一个。

三、Minus的用法

Minus:对两个结果集进行差操作,不包括重复行,同时默认排序

minus的作用是去同留异

select
*
from
(select
tu.user_name as name,tu.telephone
from
t_user tu)
minus
(select
tf.fchs_name,tf.fchs_telephone
from
t_fchs tf)

结果如下:

技术分享

备注:t_user与t_fchs的差集操作得到的结果是

t_user中与t_fchs表中相同的去掉了,不同的(只针对t_user表)留下来了。



oracle --union和union all

标签:

人气教程排行