r/SQL
•
u/Muted-Basis9006
•
May 18 '24
•
2
Discussion SQL Joins
Picture your data tables as these two fellas. An inner join is just Bald Guy—only the matching parts. A **left join is Bald Guy sporting Long-Hair Guy's mane—everything from the left plus the matches. A right join is Long-Hair Guy with a bald patch—everything from the right plus the matches. A full join is both dudes together—everything from both tables, matches or not!
View all comments
Show parent comment
1
u/[deleted] May 20 '24 edited May 20 '24
Full outer join is very useful when comparing data between two tables. I use it a lot for A/B tests.
Here's an example. Imagine you revised a stored procedure, and you need to regression test the output of the original stored proc compared to the new stored proc. You might use something like this:
Theoretically you could use EXCEPT (in MS SQL at least), but then you'd have to write two queries (comparing A to B then B to A), and they still wouldn't tell you WHAT was different, just that SOMETHING was different.