Contents Index Explicit join conditions (the ON phrase) Types of explicit join conditions

ASA SQL User's Guide
  Joins: Retrieving Data from Several Tables
    Explicit join conditions (the ON phrase)

Generated joins and the ON phrase


Key joins are the default if the keyword JOIN is used and no join type is specified—unless you use an ON phrase. If you use an ON phrase with an unspecified JOIN, key join is not the default and no generated join condition is applied.

For example, the following is a key join, because key join is the default when the keyword JOIN is used and there is no ON phrase:

SELECT *
FROM A JOIN B

The following is a join between table A and table B with the join condition A.x    =    B.y. It is not a key join.

SELECT *
FROM A JOIN B ON A.x = B.y

If you specify a KEY JOIN or NATURAL JOIN and use an ON phrase, the final join condition is the conjunction of the generated join condition and the explicit join condition(s). For example, the following statement has two join conditions: one generated because of the key join, and one explicitly stated in the ON phrase.

SELECT *
FROM A KEY JOIN B ON A.x = B.y

If the join condition generated by the key join is A.w    =    B.z, then the following statement is equivalent:

SELECT *
FROM A JOIN B
  ON A.x = B.y
  AND A.w = B.z

For more information about key joins, see Key joins.


Contents Index Explicit join conditions (the ON phrase) Types of explicit join conditions