Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 12.0.1 » SQL Anywhere Server - SQL Usage » Query and modify data » Joins: Retrieving data from several tables » How joins work

 

Joins between more than two tables

With SQL 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, SQL Anywhere evaluates the statement from left to right. Therefore, A JOIN B JOIN C is equivalent to ( A JOIN B ) JOIN C. Also, the following two SELECT statements are equivalent:

SELECT *
FROM A JOIN B JOIN C JOIN D;
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.

 See also