INF: Using the "*=" and "=*" (Outer Join) OperatorsID: Q67753
|
An outer join is defined as:
A join that includes all rows from the outer table, regardless of whether there is a matching row in the inner table. If there is no matching row in the inner table, or if the join condition is not met, the second table generates a "NULL" result as a match for that row.
Table1 Table2
---------------------- --------------------------
| Col1 | Col2 | | Col3 | Col4 |
---------------------- --------------------------
1 | 1 1 | 11
2 | 2 3 | 13
3 | 3
4 | 4
SELECT * FROM TABLE1, TABLE2
WHERE COL1 *= COL3
Col1 Col2 Col3 Col4
---------------------------------
1 | 1 | 1 | 11
2 | 2 | NULL | NULL
3 | 3 | 3 | 13
4 | 4 | NULL | NULL
SELECT * FROM TABLE1, TABLE1
WHERE COL1 =* COL3
Col1 Col2 Col3 Col4
---------------------------------
1 | 1 | 1 | 11
3 | 3 | 3 | 13
SELECT * FROM TABLE1, TABLE2
WHERE COL1 *= COL3
AND COL4 = NULL
Col1 Col2 Col3 Col4
---------------------------------
1 | 1 | 1 | 11
2 | 2 | NULL | NULL
3 | 3 | 3 | 13
4 | 4 | NULL | NULL
Col1 Col2 Col3 Col4
---------------------------------
2 | 2 | NULL | NULL
4 | 4 | NULL | NULL
Col1 Col2 Col3 Col4
---------------------------------
1 | 1 | 1 | NULL
2 | 2 | NULL | NULL
3 | 3 | 3 | NULL
4 | 4 | NULL | NULL
Col1 Col2 Col3 Col4
---------------------------------
1 | 1 | 1 | NULL
2 | 2 | NULL | NULL
3 | 3 | 3 | 13
4 | 4 | NULL | NULL
SELECT * FROM TABLE1, TABLE2
WHERE COL1 *= COL3
AND COL4 = NULL
Col1 Col2 Col3 Col4
---------------------------------
2 | 2 | NULL | NULL
4 | 4 | NULL | NULL
Keywords : kbusage SSrvServer
Version : 4.2
Platform : OS/2
Issue type :
Last Reviewed: March 10, 1999