Outer Joins
Sybase supports both of the following:
the ANSI-compliant syntax for outer joins with the join condition in the
FROM clause.
the Sybase-specific syntax using the Sybase join operator (*=) in the
WHERE clause (ANSI-noncompliant)
See the section “Outer Joins,” in the DB Interface Module User's Guide, for information on constructing outer joins.
The following example shows how you would write an outer join for Sybase. You may assume that
myDbase is a valid
RWDBDatabase instance.
An Outer Join for Sybase in ANSI-Noncompliant Syntax
RWDBTable employee = myDbase.table("emp");
RWDBTable depart = myDbase.table("dept");
RWDBTable locate = myDbase.table("loc");
RWDBSelector selector = myDbase.selector();
selector << employee["empnum"] << employee["ename"]
<< employee["deptno"] << depart["deptno"] << depart["dname"]
<< depart["locno"] << locate["locno"] << locate["lname"];
// Specify the join condition in the WHERE clause using the
// leftOuterJoin() and rightOuterJoin() methods on the columns and
// expressions. The first criterion creates a right outer join
// between the tables emp and dept by their deptno columns.
// The second criterion creates a left outer join between
// the tables dept and loc by their locno columns.
selector.where(employee["deptno"].rightOuterJoin(depart["deptno"])
&& depart["locno"].leftOuterJoin(locate["locno"]));
NOTE: Sybase does not support outer joins in which one table is outer to more than one other table. Attempting this will cause unexpected results.