WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

SQL FULL OUTER JOIN Keyword


SQL FULL OUTER JOIN Keyword

The FULL OUTER JOIN keyword returns all rows from the left table (demo1) and from the right table (demo2).

The FULL OUTER JOIN keyword combines the result of both LEFT and RIGHT joins.

SQL FULL OUTER JOIN Syntax

SELECT column_name(s)
FROM demo1
FULL OUTER JOIN demo2
ON table1.column_name=table2.column_name;

Database

In this tutorial we will use the well-known database.

Below is a selection from the "Customers" table:

CustomerID CustomerName Username Password Email Phone
1

Anthony H. Lewis Asome1952 rabuW4wah AnthonyHLewis@dayrep.com 901-849-6855
2 Gabriela A. Tilley Youcent eothah4ya4Ah GabrielaATilley@jourrapide.com 425-507-2061
3 Raymond L. Goss Thopecive47 ahh8Eenoasa RaymondLGoss@teleworm.us 559-847-0467

And a selection from the "Orders" table:

OrderID CustomerID EmployeeID OrderDate ShipperID
501 2 9 January 25, 1965 3
502 37 10 October 12, 1984 1
503 77 11 September 28, 1996 2

SQL FULL OUTER JOIN Example

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

SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
FULL OUTER JOIN Orders
ON Customers.CustomerID=Orders.CustomerID
ORDER BY Customers.CustomerName;

A selection from the result set may look like this:

CustomerName OrderID
Janet L. Gomez  
James A. Thomas 501
Frank C. Lillie 502
  503
  504