When you specify a NATURAL JOIN and put a join condition in an ON clause, the result is the conjunction of the two join conditions.
For example, the following two queries are equivalent. In the first query, SQL Anywhere generates the join condition
Employees.DepartmentID = Departments.DepartmentID. The query also contains an explicit join condition.
SELECT GivenName, Surname, DepartmentName FROM Employees NATURAL JOIN Departments ON Employees.ManagerID = Departments.DepartmentHeadID;
The next query is equivalent. In it, the natural join condition that was generated in the previous query is specified in the ON clause.
SELECT GivenName, Surname, DepartmentName FROM Employees JOIN Departments ON Employees.ManagerID = Departments.DepartmentHeadID AND Employees.DepartmentID = Departments.DepartmentID;
|Send feedback about this page via email or DocCommentXchange||Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0|