The OUTER JOIN clause differs from the standard JOIN clause (also known as the INNER JOIN clause) in that rows are returned even when there are no matches through the JOIN critieria on the second table.
Use the SQL OUTER JOIN whenever multiple tables must be accessed through a SQL SELECT statement and results should be returned if there is not a match between the JOINed tables.
Right Outer Join
A Right Outer Join will take two tables and join them together based on the linking field.
A Right Outer Join will include ALL entries from the table on the RIGHT.
Syntax
SELECT * FROM table_name1 OUTER table_name2
ON table_name1.column_name = table_name2.column_name
Example
Code:
SELECT *FROM employee RIGHT OUTER JOIN department
ON employee.DepartmentID = department.DepartmentID
Left Outer Join
A Left Outer Join will take two tables and join them together based on the linking field
A Left Outer Join will include ALL entries from the table on the LEFT
Syntax
SELECT * FROM table_name1 LEFT OUTER JOIN table_name2
ON table_name1.column_name = table_name2.column_name
Example
Code:
SELECT * FROM employee LEFT OUTER JOIN department
ON employee.DepartmentID = department.DepartmentID
Bookmarks