Contents Index Types of explicit join conditions Cross joins

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

Using the WHERE clause for join conditions


Except when using outer joins, you can specify join conditions in the WHERE clause instead of the ON phrase. However, you should be aware that there may be semantic differences between the two if the query contains outer joins.

The ON phrase is part of the FROM clause, and so is processed before the WHERE clause. This does not make a difference to results except in the case of outer joins, where using the WHERE clause can convert the join to an inner join.

When deciding whether to put join conditions in an ON phrase or WHERE clause, keep the following rules in mind:

In the examples in this documentation, join conditions are put in an ON phrase. In examples using outer joins, this is necessary. In other cases it is done to make it obvious that they are join conditions and not general search conditions.


Contents Index Types of explicit join conditions Cross joins