SQL$HELP72.HLB  —  Select Expressions, Arguments  LEFT_OUTER_JOIN
    Preserves all rows in the left-specified table reference and
    matches to rows in the right-specified table reference in the
    result. NULL appears in columns where there is no match in the
    right-specified table. For example:

    SQL> SELECT *
    cont> FROM TABLE1 LEFT OUTER JOIN TABLE2
    cont> ON TABLE1.C1 = TABLE2.C1;
       TABLE1.C1     TABLE1.C2     TABLE2.C1   TABLE2.C4
              10            15            10   AA
              20            25            20   CC
              30            35          NULL   NULL
    3 rows selected

    Basically, outer joins are an inner join with a union adding NULL
    to all unmatched rows. Notice that the LEFT OUTER JOIN example
    results are the same as the INNER JOIN example results plus the
    unmatched row.

    The search condition specified in the ON clause is used to
    construct the outer join result. In addition to the join
    predicates, you can specify selection predicates and subqueries
    in the ON clause. For example:

    SQL> SELECT *
    cont> FROM TABLE1 LEFT OUTER JOIN TABLE2
    cont> ON TABLE1.C1 = TABLE2.C1
    cont> AND C2 BETWEEN 25 AND 35;
       TABLE1.C1     TABLE1.C2     TABLE2.C1   TABLE2.C4
              10            15          NULL   NULL
              20            25            20   CC
              30            35          NULL   NULL
    3 rows selected

    A select condition in the ON clause reduces the inner join
    result. The left outer join result contains the inner join result
    plus each row from TABLE1 that did not match a row in TABLE2 and
    was extended with NULL.

    In contrast, the result from the following example uses the same
    selection condition but with the WHERE clause:

    SQL> SELECT *
    cont> FROM TABLE1 LEFT OUTER JOIN TABLE2
    cont> ON TABLE1.C1 = TABLE2.C1
    cont> WHERE C2 BETWEEN 25 AND 35;
       TABLE1.C1     TABLE1.C2     TABLE2.C1   TABLE2.C4
              20            25            20   CC
              30            35          NULL   NULL
    2 rows selected

    In the previous example, the left outer join result is first
    constructed using the search condition in the ON clause. Then the
    selection condition in the WHERE clause is applied to each row in
    the outer join result to form the final result.
Close Help