Outer Joins
An outer join is created when records needs to be included in the results without having a corresponding records in the join tables. These records are matched with the NULL records so that they are included in the output
An outer join can be created by using the WHERE clause with an outer join operator or the OUTER JOIN keywords
limitations when using the traditional approach to outer joins:
- The outer join operator can be used for only one table in the joining condition.In other words, you can’t create NULL rows in both tables at the same time.
- A condition that includes the outer join operator can’t use the IN or ORoperator.
Outer Joins: JOIN Method
When creating a traditional outer join with the outer join operator, the join can be applied to only one table—not both. However, with the JOIN keyword, you can specify which table the join should be applied to by using a left, right, or full outer join. Left and right outer joins specify which table the outer join should be applied to, based on the table’s location in the join condition. For example, a left outer join instructs Oracle to keep any rows in the table listed on the left side of the join condition, even if no matches are found with the table listed on the right. A full outer join keeps all rows from both tables in the results, no matter which table is deficient when matching rows. (That is, it performs a combination of left and right outer joins.)
SELECT c.lastname, c.firstname, o.order# FROM customers c LEFT OUTER JOIN orders o USING (customer#) ORDER BY c.lastname, c.firstname
A full join can’t be used with the outer join operator; it can be used only with the JOIN keyword.