Two Table Outer Join With Multiple Conditions
- Last Updated: May 12, 2026
- 1 minute read
- OpenAccess SDK
- Version 8.1
- Documentation
SELECT * FROM CUSTOMER t1
LEFT OUTER JOIN ORDERS t2
ON t1.custno = t2.custno
AND t1.custname = t2.custname
For this query, the IP execute will be called to execute the query on the customer table. The following shows how the IP can determine the conditions and build the results:
-
Check the Process Order of the table being processed using
dam_getInfo(DAM_INFO_QUERY_PROCESS_ORDER)and get the Join size usingdam_getInfo(DAM_INFO_JOIN_QUERY_SIZE). In this case JOIN_QUERY_SIZE will be 2 and QUERY_PROCESS_ORDER will be 0. -
The IP will call
dam_describeTableByProcessOrder()to get details of each table in the query.dam_describeTableByProcessOrder (iTableProcess Order=0)will returnCUSTOMERtable information and the TableNum of theCUSTOMERtable will be returned as 0.dam_describeTableByProcessOrder(iTableProcess Order=1)will returnORDERStable information and the TableNum of theORDERStable will be returned as 1.
-
The IP can begin to get the search condition (filter condition) on each of the tables.
-
dam_getTableSearchExp(iTableNum=0)returns:SearchExpression: NULLJoin Expression: NULLJoinType: N/A -
dam_getTableSearchExp(iTableNum=1)returns:SearchExpression: NULLJoinType: SQL_JOIN_OUTERJoin Expression: orders.custno = customer.custno ANDorders.custname = customer.custname
-
-
The IP can then build results for the
CUSTOMERtable and a pushdown join rowset for the correspondingORDERStable. If no matching orders are found, the IP should add an empty rowset for theORDERStable. -
If the IP only builds results for
ORDERStable, the IP EXECUTE function is called for matchingCUSTOMERSrecords. In this case, to get the column values for each of the join columns in the Join Expression, the IP can calldam_getJoinColValue(iTableNum, iColumnNum, int *piXoType, void *pColData, int *piColDataLen)