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
SQL
x
1
SELECT table1.column1, table2.column2
2
FROM table1
3
FULL OUTER JOIN table2
4
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:
SQL
1
1
SELECT Patients.first_name, Appointments.appointment_date
2
FROM Patients
3
FULL OUTER JOIN Appointments
4
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.