Progress
Programming
Handbook
Using Left Outer Joins
A left outer join is useful where you want to see all the data on the left side, whether or not there is related data on the right. For example, you might want to see the proportion of customers who are ordering close to their credit limit as against those who are not.
The query in
p-join2.p
is identical to the one inp-join1.p
(see the "Using Inner Joins" section) except that all the joins are left outer joins instead of inner joins. Thus, you see all customers, whether or not they order close to their credit limit. These three items correspond to the/*1*/
,/*2*/
, and/*3*/
that label the joins in thep-join2.p
example:
- To each Customer, join all related Order records, or join a null Order record if the customer has no orders.
- To each Order in the previous join, join each related Order–Line record whose total purchase is greater than two–thirds the customer’s credit limit, or join a null Order–Line record if all item purchases are less than or equal to two–thirds the customer’s credit limit. Also, join a null Order–Line record if the order is null (the customer has no orders).
- To each Order–Line in the previous join, join the related Item record to get the item name, or join a null Item record if the the Order–Line is null (no Order or selected purchase for that customer).
When executed, you get the output shown in Figure 9–6. In this example, you see the same golf club order as in Figure 9–5 along with many other orders that do not meet the selection criteria and some customers who have no orders at all.
Figure 9–6: Left Outer Join Example
![]()
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |