输入banner图图片脚本导航/分类

oracle --union和union all

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

标签: