什么时候使用全外连接比较合适? [英] When is a good situation to use a full outer join?

查看:49
本文介绍了什么时候使用全外连接比较合适?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我总是不鼓励使用一种方法,但有没有一种情况是最好的方法?

I'm always discouraged from using one, but is there a circumstance when it's the best approach?

推荐答案

这很少见,但我有几个使用它的案例.通常在异常报告或 ETL 或其他双方都有数据的非常特殊的情况下您正在尝试合并.
另一种方法是使用INNER JOINLEFT JOIN(右侧IS NULL)和RIGHT JOIN>(左侧 IS NULL)并执行 UNION - 有时这种方法更好,因为您可以更明显地自定义每个单独的连接(并添加派生列以指示哪个边是否找到,或者是否在两者中都找到了,哪一个会赢).

It's rare, but I have a few cases where it's used. Typically in exception reports or ETL or other very peculiar situations where both sides have data you are trying to combine.
The alternative is to use an INNER JOIN, a LEFT JOIN (with right side IS NULL) and a RIGHT JOIN (with left side IS NULL) and do a UNION - sometimes this approach is better because you can customize each individual join more obviously (and add a derived column to indicate which side is found or whether it's found in both and which one is going to win).

这篇关于什么时候使用全外连接比较合适?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆