Natural joins

When you specify a natural join, SQL Anywhere generates a join condition based on columns with the same name. For this to work in a natural join of base tables, there must be at least one pair of columns with the same name, with one column from each table. If there is no common column name, an error is issued.

If table A and table B have one column name in common, and that column is called x, then

SELECT *
FROM A NATURAL JOIN B;

is equivalent to the following:

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

If table A and table B have two column names in common, and they are called a and b, then A NATURAL JOIN B is equivalent to the following:

A JOIN B
 ON A.a = B.a
 AND A.b = B.b;
 Example 1
 Example 2

Errors using NATURAL JOIN
Natural joins with an ON clause
Natural joins of table expressions
Natural joins of views and derived tables