[英]Perform Union using joins not union ALL
We are having a requirement where in we are trying to perform union operation for the tables of 2 different databases using informatica cloud, we dont have union transformation in it. 我们有一个要求,即我们试图使用Informatica云对2个不同数据库的表执行联合操作,但其中没有联合转换。 So trying to explore if this can be performed using a left/full outer join ?
因此,尝试探索是否可以使用左/全外部联接来执行此操作?
select * from t join p on t.id = p.id
union
select * from t join p on t.id = p.id2
Note: Not Union ALL only Union 注意:不是联合所有联合
The difference between union
and union all
is simply the removal of distinct values. union
和union all
之间的区别只是简单地去除了不同的值。 The answer to your question is that you can emulate union
using a bunch of coalesce()
statements, select distinct
, and full join
. 您的问题的答案是,您可以使用一堆
coalesce()
语句模拟union
, select distinct
和full join
。
However, why not just do: 但是,为什么不这样做:
select *
from t join
p
on t.id in (p.id, p.id2);
Depending on the data, you might need select distinct
: 根据数据,您可能需要
select distinct
:
select distinct *
from t join
p
on t.id in (p.id, p.id2);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.