SQL adaptation guide For Sybase ASE 15.5+ / Data manipulation |
The original OUTER join syntax of Informix® is different from the Sybase ASE outer join syntax:
SELECT ... FROM cust, OUTER(order) WHERE cust.key = order.custno SELECT ... FROM cust, OUTER(order,OUTER(item)) WHERE cust.key = order.custno AND order.key = item.ordno AND order.accepted = 1
SELECT ... FROM cust LEFT OUTER JOIN order ON cust.key = order.custno SELECT ... FROM cust LEFT OUTER JOIN order LEFT OUTER JOIN item ON order.key = item.ordno ON cust.key = order.custno WHERE order.accepted = 1
SELECT ... FROM a, b WHERE a.key *= b.key
See the Sybase ASE reference manual for a complete description of the syntax.
For better SQL portability, you should use the ANSI outer join syntax instead of the old Informix OUTER syntax.
The Sybase ASE interface can convert simple Informix OUTER specifications to Sybase ASE ANSI outer joins.
Prerequisites:
Example: "WHERE tab1.col1 = tab2.col2 ".
Example: "... FROM tab1, OUTER(tab2) WHERE tab1.col1 = tab2.col2 AND tab2.colx > 10".
Example: "SELECT ... UNION SELECT" or "SELECT ... WHERE col IN (SELECT...)"
OUTER example with table alias: "OUTER( tab1 alias1)".
OUTER join example with table on the left: "WHERE outertab.col1 = maintab.col2 ".
Example: "SELECT ... FROM tab1, TAB2 WHERE tab1.col1 = tab2.col2".