ODBC outer join syntax
In ODBC, you can use outer join syntax in a vendor escape clause to make outer joins portable in your SQL statements.
The following extended SQL syntax specifies an outer join.
- table-name
- Specifies the name of the table that you want to join.
- LEFT
- Performs a left outer join.
- RIGHT
- Performs a right outer join.
- FULL
- Performs a full outer join.
- table-name
- Specifies the name of the table that you want to join with the previous table.
- outer-join
- Specifies the result of an outer join that you want to join with the previous table. (Use the syntax above without the leading keyword oj.)
- search-condition
- Specifies the condition on which rows are joined.
Example: You can use either of the following forms
of the escape clause to perform an outer join. In this example, a
vendor escape clause specifies the outer join in each SQL statement.
- Short-form syntax:
SELECT * FROM {oj T1 LEFT OUTER JOIN T2 ON T1.C1=T2.C3} WHERE T1.C2>20
- Long-form syntax:
SELECT * FROM --(*vendor(Microsoft),product(ODBC) oj T1 LEFT OUTER JOIN T2 ON T1.C1=T2.C3*)-- WHERE T1.C2>20
Important: Not all servers support outer join.
To determine if the current server supports outer joins, call SQLGetInfo()
twice,
first with the InfoType argument set to
SQL_OUTER_JOINS, and then with the InfoType argument
set to SQL_OJ_CAPABILITIES.