Java Reference
In-Depth Information
Figure 9-5:
Tables joined on customer number
The two tables are shown in the rounded boxes, and the Joined fields are shaded.
Using an Inner Join, as shown in the last example, you can only list customers who have placed an
order, so their customer numbers fall into the shaded area of
Figure 9-5
. If you want a list of all
customers, together with the dates of any orders they have placed, you can't get there with an Inner
Join.
An
Outer Join
can include not only records inside the union of the sets or tables, but records outside
the union of the sets, as well. In other words, in addition to the set members that share customer
numbers, you can get customers in the lower, or "Outer," part of the joined tables.
There are three types of Outer Joins:
LEFT OUTER JOIN (*=)
RIGHT OUTER JOIN (=*)
FULL OUTER JOIN
The terms LEFT, RIGHT, and FULL describe which of the tables' unmatched columns to include in the
Join relative to the order in which the tables appear in the
JOIN
command.
LEFT OUTER JOIN
The
LEFT OUTER JOIN
operator includes all rows from the left side of the Join, as shown in
Figure 9-6
.
Figure 9-6:
Executing a LEFT OUTER JOIN
RIGHT OUTER JOIN