Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is a good situation to use a full outer join?

Tags:

sql

sql-server

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

like image 428
Nick Avatar asked Jan 19 '10 15:01

Nick


People also ask

In which case would you use a full outer join?

We use a FULL OUTER JOIN in Oracle when we want all unmatched data from both tables. Explanation: Oracle9i also makes it possible for you to easily execute a full outer join, including all records from the tables that would have been displayed if you had used both LEFT OUTER JOIN or RIGHT OUTER JOIN clauses.

Why we use full join?

The SQL FULL JOIN command LEFT JOIN and RIGHT JOIN each return unmatched rows from one of the tables— FULL JOIN returns unmatched rows from both tables. It is commonly used in conjunction with aggregations to understand the amount of overlap between two tables.


1 Answers

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).

like image 190
Cade Roux Avatar answered Oct 12 '22 00:10

Cade Roux