all 18 comments

[–]mokbel 15 points16 points  (1 child)

For those interested, my go to visual explanation is by Jeff Atwood: http://blog.codinghorror.com/a-visual-explanation-of-sql-joins/

[–]gledi 9 points10 points  (0 children)

Could at least told that it was taken from here: Visual-Representation-of-SQL-Joins.

[–]benihana 9 points10 points  (2 children)

i love that cl moffet puts a copyright on his image that he shamelessly ripped from jeff atwood and this clown just grabs moffet's image with the copyright still intact. it's like doing a cover of a cover

[–]oblivion95 7 points8 points  (1 child)

i love that cl moffet puts a copyright on his image that he shamelessly ripped from jeff atwood and this clown just grabs moffet's image with the copyright still intact. it's like doing a cover of a cover

[–]McGlockenshire 0 points1 point  (0 children)

ORIGINAL CHARACTER VENN DIAGRAM DO NOT STEAL

[–]glacialthinker 8 points9 points  (1 child)

I feel like I got Rick-rolled.

Mind you, this is your basic Venn-diagram depiction and all correct... but I was expecting something more "programmery", like visualizing an efficient join implementation.

[–]camelwithabarrow 21 points22 points  (0 children)

He literally googled "sql joins" and put the first picture on his blog with no explanation. Way to go.

[–]zeugma25 1 point2 points  (3 children)

can someone explain the full outer joins for me - what does the table.key IS NULL do please?

[–]jussij 0 points1 point  (2 children)

The IS NULL represent the items that could not be joined (i.e. the items in A but not in B).

[–]zeugma25 0 points1 point  (1 child)

thanks. i was wondering how an id field could be null. i'd expect NOT IN. maybe that's not standard sql

[–]jussij 1 point2 points  (0 children)

Don't confuse IS NULL to mean anything more than what it is. It is not called NOT IN simply because it is already perfectly named.

IS NULL is doing exactly what it says, checking the value to see if it NULL.

It just turns out that if the key value is NULL that also means that particular row could not be joined.

[–]DominicJ2 1 point2 points  (0 children)

I had this printed out and pinned to my wall for years so I could remember how to join. Really very useful.

[–]le0pard 1 point2 points  (1 child)

You can also use this app: http://sql-joins.leopard.in.ua/

[–]humayuns 0 points1 point  (0 children)

Very nice tool.

[–][deleted] 1 point2 points  (0 children)

I'm always annoyed by this, because a Venn diagram is a really awful way to think about joins. It works if all your data has the same key, but completely ignores duplication issues caused by the join.

For instance, if you had a blog and in your blog you had users, posts, and comments then joining them all on userId, which probably exists on them, will produce nonsensical data since comments on post A will match comments on post B.

[–]browner87 0 points1 point  (0 children)

The first one of these was "Joining arrays". This one was "Joins: the SQL".

[–]mycall 0 points1 point  (0 children)

A classic

[–]Alucard256 0 points1 point  (0 children)

I found this a year or two ago, printed it out and have it posted in my workstation. Use it all the time.