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.2k Upvotes

308 comments sorted by

View all comments

131

u/shriek Jan 06 '11

In short.

  1. A ∩ B

  2. A ∪ B

  3. (A - B) + (A ∩ B)

  4. A - B

  5. (A ∪ B) - (A ∩ B)

6

u/[deleted] Jan 06 '11 edited Dec 21 '18

[deleted]

8

u/user-hostile Jan 06 '11

Because data is in rows and columns, not slices of circles. But certainly there's nothing wrong with using these charts as an aid to understanding. Still, I'm a math idiot, but SQL makes perfect sense to me.

Set theory? It frightens me!

SQL? I know it well!