SQL FULL JOIN
SQL

SQL FULL JOIN — How to Combine All Rows from Both Tables

CHAPTER 24 of 30 SQL Tutorial — Free Course on Neotech Navigators
The SQL FULL OUTER JOIN returns all rows from both tables, matching rows where possible and filling in NULL where there is no match on either side. It combines the behavior of LEFT JOIN and RIGHT JOIN. In this chapter, you will learn the FULL JOIN syntax, see a practical example, and understand when to use it.

SQL FULL JOIN Syntax

SQL — FULL JOIN Syntax
SELECT columns
FROM table1
FULL OUTER JOIN table2
  ON table1.column = table2.column;

FULL OUTER JOIN and FULL JOIN are identical — the keyword OUTER is optional.

Sample Tables

We will use the same Employees and Departments tables from the Joins Introduction:

TABLE: Employees
+----+-----------+--------+--------+
| ID | Name      | DeptID | Salary |
+----+-----------+--------+--------+
| 1  | Priya K.  | 101    | 55000  |
| 2  | John D.   | 102    | 62000  |
| 3  | Arun M.   | 101    | 78000  |
| 4  | Emma W.   | 103    | 51000  |
| 5  | Ravi S.   | NULL   | 72000  |
+----+-----------+--------+--------+
TABLE: Departments
+-----+----------------+-----------+
| ID  | DeptName       | Location  |
+-----+----------------+-----------+
| 101 | IT             | Delhi     |
| 102 | Marketing      | London    |
| 103 | Sales          | Mumbai    |
| 104 | HR             | New York  |
+-----+----------------+-----------+

SQL FULL JOIN Example

This query joins all rows from both tables. Unmatched rows on either side appear with NULL:

SQL
SELECT e.Name, d.DeptName, e.Salary
FROM Employees AS e
FULL OUTER JOIN Departments AS d
  ON e.DeptID = d.ID;
✓ OUTPUT
+-----------+-----------+--------+
| Name      | DeptName  | Salary |
+-----------+-----------+--------+
| Priya K.  | IT        | 55000  |
| John D.   | Marketing | 62000  |
| Arun M.   | IT        | 78000  |
| Emma W.   | Sales     | 51000  |
| Ravi S.   | NULL      | 72000  |
| NULL      | HR        | NULL   |
+-----------+-----------+--------+

Ravi S. appears with NULL DeptName (no department). HR appears with NULL Name and Salary (no employees). FULL JOIN keeps every row from both tables.

Find Unmatched Rows on Both Sides

Use WHERE to find rows that have no match in the other table:

SQL — Orphan Rows Only
SELECT e.Name, d.DeptName
FROM Employees AS e
FULL OUTER JOIN Departments AS d
  ON e.DeptID = d.ID
WHERE e.ID IS NULL
   OR d.ID IS NULL;
✓ OUTPUT
+-----------+-----------+
| Name      | DeptName  |
+-----------+-----------+
| Ravi S.   | NULL      |
| NULL      | HR        |
+-----------+-----------+

FULL JOIN vs Other JOIN Types

JOIN Type Left Unmatched Right Unmatched Both Matched
INNER JOIN Excluded Excluded Included
LEFT JOIN Included (NULL right) Excluded Included
RIGHT JOIN Excluded Included (NULL left) Included
FULL JOIN Included (NULL right) Included (NULL left) Included

⚠️ MySQL Does Not Support FULL OUTER JOIN

MySQL does not have native FULL OUTER JOIN support. You can simulate it by combining a LEFT JOIN and a RIGHT JOIN with UNION:

SQL — Simulate FULL JOIN in MySQL
SELECT e.Name, d.DeptName
FROM Employees AS e
LEFT JOIN Departments AS d ON e.DeptID = d.ID
UNION
SELECT e.Name, d.DeptName
FROM Employees AS e
RIGHT JOIN Departments AS d ON e.DeptID = d.ID;

The UNION combines both results and removes duplicates automatically. PostgreSQL, SQL Server, and Oracle support FULL OUTER JOIN natively.

For the complete JOIN syntax reference, see the official MySQL JOIN documentation. In the next chapter, you will learn SQL GROUP BY to group rows and calculate aggregates.

If you work with data regularly, explore our ready-made Dashboard Templates on NextGenTemplates that use SQL-powered data for business reporting.

📺 Visit our YouTube channel @NeoTechNavigators for step-by-step video tutorials and dashboard demos on this topic.

🧪 Try It Yourself

Write a FULL OUTER JOIN query that shows every employee and every department, along with the department location. Include unmatched rows from both sides.

ANSWER
SELECT e.Name, d.DeptName, d.Location
FROM Employees AS e
FULL OUTER JOIN Departments AS d
  ON e.DeptID = d.ID;

Expected Output:

+-----------+-----------+-----------+
| Name      | DeptName  | Location  |
+-----------+-----------+-----------+
| Priya K.  | IT        | Delhi     |
| John D.   | Marketing | London    |
| Arun M.   | IT        | Delhi     |
| Emma W.   | Sales     | Mumbai    |
| Ravi S.   | NULL      | NULL      |
| NULL      | HR        | New York  |
+-----------+-----------+-----------+

📝 What You Learned in This Chapter

  • FULL OUTER JOIN returns all rows from both tables
  • Unmatched rows on either side are filled with NULL
  • It combines LEFT JOIN and RIGHT JOIN behavior
  • FULL JOIN and FULL OUTER JOIN are identical
  • MySQL does not support FULL JOIN natively — use LEFT JOIN + UNION + RIGHT JOIN
  • Use WHERE with IS NULL to find unmatched rows on either side

Frequently Asked Questions

What is a SQL FULL OUTER JOIN?
A FULL OUTER JOIN returns all rows from both the left and right tables. Where there is a match, the columns from both tables are filled. Where there is no match, the missing side is filled with NULL. It is the most inclusive type of JOIN.
Does MySQL support FULL OUTER JOIN?
No. MySQL does not support FULL OUTER JOIN natively. You can simulate it by combining a LEFT JOIN and a RIGHT JOIN with UNION. PostgreSQL, SQL Server, and Oracle all support FULL OUTER JOIN directly.
What is the difference between FULL JOIN and FULL OUTER JOIN?
There is no difference. FULL JOIN and FULL OUTER JOIN are the same. The keyword OUTER is optional and does not change the behavior.
When should I use FULL OUTER JOIN?
Use FULL OUTER JOIN when you need to see all data from both tables, including rows that have no match on either side. Common use cases include data reconciliation, finding orphan records, and comparing two datasets for mismatches.
How do I find unmatched rows using FULL JOIN?
Add WHERE table1.key IS NULL OR table2.key IS NULL after the FULL JOIN. This returns only the rows from either table that had no corresponding match — useful for identifying orphan or missing records.

📖 Chapter 24 of 30 — SQL Tutorial on Neotech Navigators

PK
Meet PK, the founder of NeotechNavigators.com! With over 15 years of experience in Data Visualization, Excel Automation, and dashboard creation. PK is a Microsoft Certified Professional who has a passion for all things in Excel. PK loves to explore new and innovative ways to use Excel and is always eager to share his knowledge with others. With an eye for detail and a commitment to excellence, PK has become a go-to expert in the world of Excel. Whether you're looking to create stunning visualizations or streamline your workflow with automation, PK has the skills and expertise to help you succeed. Join the many satisfied clients who have benefited from PK's services and see how he can take your data analysis skills to the next level!
https://neotechnavigators.com