Full outer Join in SQL with example

SQL full outer join statement returns all the rows when there is a match in either left or the right table.

Syntax: Select <field list> from table A full outer join Table B on A.Key=B.Key

Input Data:

Input table 1 (Orders)

OrderID CustomerId Product OrderDate ShipperID
10308 2 Laptop 2021-09-18 3
10309 37 Xbox 2021-09-19 2
10310 77 Laptop 2021-07-07 1


CustomerID CustomerName Phone Address City Postalcode Country
1 Mohamed Salah +2167676 Sousse Tn 2222 Sousse 2222 Tunisia
2 Emna Chachia +216879 Tunis Tn 4444 Tunis 4444 Tunisia
3 Souha Mabrouk +2167986 Annaba Algeria 85858 Annaba 85858 Algeria

2- Second, we apply the full outer join command:

Full outer Join SQL:

Select * From Orders left join Customers on Orders.CustomerId=Customers.CustomerId
Select * From Orders right join Customers on Orders.CustomerId=Customers.CustomerId;

3- Third, we have our result:

Full outer join

Read also:

How to install MySQL on windows

SQL inner Join full explanation with example

How to create a table using SQL and insert values into it

SQL Syntax


Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also
Back to top button