SQL FULL OUTER JOIN Keyword
The FULL OUTER JOIN keyword returns all records when there is a match in either the left or the right table. Records without a match in either table will still appear in the result, with NULL values where applicable.
SQL FULL OUTER JOIN Syntax
SELECT table1.column1, table2.column2 FROM table1 FULL OUTER JOIN table2 ON table1.common_column = table2.common_column;
SQL FULL OUTER JOIN Example
This SQL statement selects all patients and all appointments, even when there’s no match between them:
SELECT Patients.first_name, Appointments.appointment_date FROM Patients FULL OUTER JOIN Appointments ON Patients.patient_id = Appointments.patient_id;
Note: This example does not work in SQLite or in our TechKubo playground because
FULL OUTER JOIN
is not supported in SQLite. Use only in MySQL, PostgreSQL, SQL Server, or Oracle.