Contents Index Joining two tables Join compatible data types

ASA SQL User's Guide
  Joins: Retrieving Data from Several Tables
    Joins overview

Joining more than two tables


With Adaptive Server Anywhere, there is no fixed limit on the number of tables you can join.

When joining more than two tables, parentheses are optional. If you do not use parentheses, Adaptive Server Anywhere evaluates the statement from left to right. Therefore, A JOIN B JOIN C is equivalent to (A JOIN B) JOIN C. Another example:

SELECT *
FROM A JOIN B JOIN C JOIN D

is equivalent to

SELECT *
FROM ((A JOIN B) JOIN C) JOIN D

Whenever more than two tables are joined, the join involves table expressions. In the example A JOIN B JOIN C, the table expression A JOIN B is joined to C. This means, conceptually, that A and B are joined, and then the result is joined to C.

The order of joins is important if the table expression contains outer joins. For example, A JOIN B LEFT OUTER JOIN C is interpreted as (A JOIN B) LEFT OUTER JOIN C. This means that the table expression A JOIN B is joined to C. The table expression A JOIN B is preserved and table C is null-supplying.

For more information about outer joins, see Outer joins.

For more information about how Adaptive Server Anywhere performs a key join of table expressions, see Key joins of table expressions.

For more information about how Adaptive Server Anywhere performs a natural join of table expressions, see Natural joins of table expressions.


Contents Index Joining two tables Join compatible data types