Full Outer Joins

Finally, we have a full outer join. Joining two tables with a full outer join gives us a result set that includes all records from both tables with null values for unmatched rows.

Now that another event planner has joined Mary’s company, to get all of the events run by the company in August, we can use a full outer join to combine mary_events and leah_events.

1
2
3
4
SELECT *
FROM mary_events
FULL OUTER JOIN leah_events ON mary_events.month = leah_events.month
WHERE mary_events.month = 08;

Venn diagram with the entirety of both circles highlighted Venn diagram with the entirety of both circles highlighted

The Venn diagram above shows the result set highlighted in blue.

Check Your Understanding

Question

What does a FULL JOIN do?

  1. Returns results with matching rows in both tables
  2. Returns results with all the rows from the left table with null values for unmatched rows from the right table
  3. Returns results with all the rows from the right table with null values for unmatched rows from the left table
  4. Returns results from all the rows from both tables with null values filled in for all unmatched rows