Sql Join Full
FULL OUTER JOIN is a type of join in SQL used to retain all records from both tables, even when there is no match in one of the tables.
The result of a FULL OUTER JOIN includes records satisfying the join condition (the intersection part) as well as records not satisfying the condition (the non-intersection part of the union). If a record exists in one table but has no matching record in the other table, the missing columns for that record are filled with NULL.
The FULL OUTER JOIN keyword returns rows if there is a match in either the left table (table1) or the right table (table2).
The FULL OUTER JOIN keyword combines the results of LEFT JOIN and RIGHT JOIN.
### SQL FULL OUTER JOIN Syntax
SELECT column_name(s) FROM table1 FULL OUTER JOIN table2 ON table1.column_name=table2.column_name;
* **table1, table2**: The two tables to be joined.
* **ON table1.column_name=table2.column_name**: Specifies the join condition, usually a common field between the two tables.
* **column_name(s)**: The fields selected from both tables.

* * *
## SQL FULL OUTER JOIN Example
The following SQL statement selects all website access records.
FULL OUTER JOIN is not supported in MySQL; you can test the example below in SQL Server.
## Example
SELECT Websites.name, access_log.count, access_log.date
FROM Websites
FULL OUTER JOIN access_log
ON Websites.id=access_log.site_id
ORDER BY access_log.count DESC;
**Note:** The FULL OUTER JOIN keyword returns all rows from both the left table (Websites) and the right table (access_log). Rows from the "Websites" table that have no match in "access_log", or rows from the "access_log" table that have no match in "Websites", are also included in the result.
YouTip