SQL TutorialLesson 30Free preview
SQL Full Join
This lesson is part of SQL · All levels
Summary
FULL OUTER JOIN returns all the rows from the left and right tables; the unmatched section is filled in. Unfortunately MySQL does not support FULL JOIN directly so it must be simulated by combining LEFT JOIN and RIGHT JOIN using UNION. PostgreSQL and SQL Server fully support this command.
Key points
- FULL JOIN returns all the second row of the table with NULL for the unpaired.
- MySQL does not support FULL OUTER JOIN; simulate with LEFT JOIN UNION RIGHT JOIN.
- UNION is used to combine both results while removing duplicates.
- FULL JOIN is useful for checking the completeness of the relationship between tables.
- The INNER JOIN is just a slice of the full join result.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.