Here’s another join type to your collection: FULL OUTER JOIN
.
FULL OUTER JOIN
returns both rows from the left and right table (if the record from one table has no matched record from the other table all columns will have NULL
value).
I haven’t used FULL OUTER JOIN
for a long time (read never) and it’s another one of those interview questions.
Here’s an example query that joins library entries and users:
SELECT * FROM books_users b FULL OUTER JOIN users u ON b.user_id = u.id
IMO everything could be done via INNER
and LEFT
joins. It’s better to...