无法清楚了解Oracle中的相交

我有一个表the squre of 876 is 767376 the squre of 876 is 767376 the squre of 755 is 570025 the squre of 661 is 436921 the squre of 24532 is 601819024 the squre of 758 is 574564 the squre of 450 is 202500 the squre of 302 is 91204 the squre of 2043 is 4173849 the squre of 712 is 506944 the squre of 71 is 5041 the squre of 456 is 207936 the squre of 21 is 441 the squre of 398 is 158404 the squre of 339 is 114921 the squre of 882 is 777924 the squre of 9 is 81 the squre of 179 is the squre of 535 is the squre of 940 is the squre of 12 is 144 my squareNumbers: Array(20) [ 767376,570025,436921,601819024,574564,202500,91204,4173849,506944,5041,… ] 为:

无法清楚了解Oracle中的相交

我将相交方法用作:

managers_temp

据我了解,相交给出了两个表的通用数据:

无法清楚了解Oracle中的相交

但是当我应用该查询时,我得到的输出为:

无法清楚了解Oracle中的相交

当我改用那个查询来获取公共数据时,我得到的是除重复数据之外的数据。既然如此,相交就得到了公共数据,但是为什么这里除了公共数据之外又要来数据呢?我在这里感到困惑,因为我的预期输出是:

select id,name,age from ot.managers_temp
intersect 
select id,age from ot.managers_temp

这两个是通用数据,但除所有通用元素外,它向我显示数据吗?为什么会这样呢?

w52kdm 回答:无法清楚了解Oracle中的相交

如评论中所述。

此查询

select id,name,age from ot.managers_temp
intersect 
select id,age from ot.managers_temp

相同
select distinct id,age from ot.managers_temp

所以输出是预期的,因为intersect提供了公用数据,然后对其进行了distinct,但是在您的情况下,所有记录都是公用的,因为intersect中的两个表是相同的。

干杯!

,

Oracle INTERSECT运算符比较两个查询的结果,并返回两个查询输出的不同行。

请参见https://www.oracletutorial.com/oracle-basics/oracle-intersect/

本文链接:https://www.f2er.com/3134027.html

大家都在问