r/SQL • • Feb 11 '14

SQL Joins Explained

http://imgur.com/1m55Wqo
157 Upvotes

27 comments sorted by

View all comments

13

u/askur Feb 11 '14

These are not all SQL joins, just the equi-joins. Joins are not conditioned on the '=' operator alone (although it is the most common case).

Still the best visualization I know of, and I still use it. Along with this caveat. ;)

4

u/fazzah Feb 11 '14

Agreed. Also, isn't the JOIN clause better for optimization? I've read somewhere that it's better for the optimizer to check the relation between rows before filtering the results with WHERE clause, because a simple WHERE condition to join tables produces a cartesian result which is THEN filtered.

13

u/r3pr0b8 GROUP_CONCAT is da bomb Feb 11 '14

because a simple WHERE condition to join tables produces a cartesian result which is THEN filtered.

i don't believe any of the common database systems have an optimizer that is that stupid

2

u/fazzah Feb 11 '14

I stand corrected, a brain fart. I somehow mistaken it with HAVING, which filters the results of GROUP BY clause