HOME C C++ PYTHON JAVA HTML CSS JAVASCRIPT BOOTSTRAP JQUERY REACT PHP SQL AJAX JSON DATA SCIENCE AI

SQL FULL OUTER JOIN Keyword

The FULL OUTER JOIN keyword returns all records when there is a match in left (table1) or right (table2) table records.

The FULL OUTER JOIN and FULL JOIN are same.

Syntax

 SELECT column_name(s)
 FROM  table1
 FULL OUTER JOIN  table2
 ON  table1.column_name = table2.column_name;
 WHERE condition;
You can click on above box to edit the code and run again.

Note: The FULL OUTER JOIN can potentially return very large result-sets! .

Demo Employee table


This employee table is used for examples:

demo table

Demo Products table


This product table is used in examples:

demo products table

SQL FULL OUTER JOIN Example


The following SQL statement selects all customers, and all orders:


Example

 SELECT  employee.Employee_name, products.Product_id 
 FROM  employee
 FULL OUTER JOIN products
 ON  employee.Employee_id = products.Employee_id
 ORDER BY employee.Employee_name;
You can click on above box to edit the code and run again.

Note: The FULL OUTER JOIN keyword returns all matching records from both tables whether the other table matches or not. So, if there are rows in "employee" that do not have matches in "products", or if there are rows in "products" that do not have matches in "employee", those rows will be listed as well.