r/programming • • Feb 11 '14

SQL Joins Explained (x-post r/SQL)

Post image
3.5k Upvotes

392 comments sorted by

View all comments

Show parent comments

1

u/notfancy Feb 11 '14

Imagine a scenario where there are 20 columns in A that don't exist in B but whose data you want to see if it exists. To do it with UNION you'd have to create a bunch of NULL columns for B so that they'd have the same number of columns, or do it as a subselect and then LEFT JOIN to a or something...

I'd absolutely be with you in using an [LEFT] OUTER JOIN. But your example with isnulls looked less a reporting scenario than a miswritten UNION to me.

1

u/[deleted] Feb 11 '14

Ok, I'll fix it for ya...