Note: It is very common for a WHERE clause to accidentally eliminate rows in
an OUTER JOIN. Typically, a LEFT OUTER JOIN or RIGHT OUTER JOIN becomes an INNER JOIN, or a FULL OUTER JOIN becomes a LEFT or RIGHT OUTER JOIN. Heres the technical explanation for this symptom: Any null-intolerant predicate that refers to attributes from a null-supplying table will eliminate NULL-supplied rows from the result. A null-intolerant predicate is a predicate that cannot evaluate to true if any of its inputs are NULL. Most SQL predicates, such as comparisons, LIKE, or IN predicates, are null-intolerant. Examples of null-tolerant predicates are IS NULL and any predicate p qualified by a null-tolerant truth value test, such as p IS NOT TRUE. (from Semantics and Compatibility of Transact-SQL Outer Joins by G. N. Paulley, 15 February 2002, iAnywhere Solutions Technical White Paper, Document Number 1017447.)
3.6 Multi-Table Joins
The syntax of the FROM clause allows for joins among endless numbers of tables, with or without parentheses to create nested table expressions, and with or without ON conditions on each join. In most cases, parentheses are not required, but it is a very good idea to provide an ON condition for every join operator whenever possible. <table_expression> ::= <table_term> | <table_expression> CROSS JOIN <table_term> | <table_expression> [ <on_condition_shorthand> ] -- do not use <join_operator> <table_term> [ <on_condition> ] -- use this instead <table_term> ::= <table_reference> | <view_reference> | <derived_table> | <procedure_reference> | "(" <table_expression_list> ")" | <lateral_derived_table> <on_condition_shorthand> ::= KEY -- foreign key columns; do not use | NATURAL -- like-named columns; do not use <join_operator> ::= <inner_join> | <left_outer_join> | <right_outer_join> | <full_outer_join> In the absence of parentheses, join operators are evaluated from left to right. That means the first pair of table terms are joined to create a virtual table, then that virtual table is joined to the third table term to produce another virtual table, and so on. The following example shows a four-way join among tables that exist in the ASADEMO database that ships with SQL Anywhere Studio 9. Here is the schema for the four tables (customer, product, sales_order, and sales_order_items) plus two other tables that will appear in later examples (employee and fin_code): CREATE TABLE customer ( id INTEGER NOT NULL DEFAULT AUTOINCREMENT, fname CHAR ( 15 ) NOT NULL, lname CHAR ( 20 ) NOT NULL,