使用连接而不是 union ALL 执行联合

Perform Union using joins not union ALL

我们有一个要求,在我们尝试使用 informatica cloud 对 2 个不同数据库的表执行并集操作时,我们没有在其中进行并集转换。因此,尝试探索是否可以使用 left/full 外连接来执行此操作?

select * from t join p on t.id = p.id
union
select * from t join p on t.id = p.id2

注意:不是 Union ALL 只有 Union

unionunion all 之间的区别只是删除了不同的值。您的问题的答案是您可以使用一堆 coalesce() 语句、select distinctfull join.

来模拟 union

但是,为什么不这样做:

select *
from t join
     p
     on t.id in (p.id, p.id2);

根据数据,您可能需要 select distinct:

select distinct *
from t join
     p
     on t.id in (p.id, p.id2);