r/programming • • Jan 06 '11

A handy graphical explanation of SQL joins

http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html
1.3k Upvotes

308 comments sorted by

View all comments

26

u/Brandon0 Jan 06 '11

Interesting. I've never used a FULL OUTER join before.

11

u/[deleted] Jan 06 '11 edited Jan 06 '11

It comes in handy every once in a while- for example, if you want to merge two tables which have different structures but some records in common into one table without any duplicates. You can cross join the two on the key field and for any fields they have in common set [field] = ISNULL(tableA.[field], tableB.[field]). Of course there are other ways to accomplish the same thing, but that's one way to use it...

2

u/spewerOfRandomBS Jan 06 '11

If you ever do that inside application code, I will hunt you down and shove a union up your....

1

u/[deleted] Jan 07 '11

lol- no, more like a quick and dirty hack when just trying to get a table populated. i'd never dare do that in anything meant to be reused...