Harry Shmedlap
Registered User.
- Local time
- Today, 15:24
- Joined
- Aug 9, 2005
- Messages
- 51
It seems to me that one join-related failure in an Access 2003 query is when one of the fields involved in the join has null values. One way this happens is if an outer join is followed by an inner join. For example "F LEFT JOIN G" will produce full field values for both F and G fields, only in records where there is a match between the joined fields. If there are any additional records in the F table (due to the LEFT join), then only the fields of F will be included in the output, while all the G field values will necessarily be null. If this is followed by an inner join on H, where the join is done in one of G's fields then, these null values will cause this inner join to fail. Alternatively if the first join was "F RIGHT JOIN G" then, since this time all of G's values will be included, then the subsequent inner join with H should not fail.
Such is my understanding. However I don't understand the Access Help statement, under the topic of "LEFT JOIN, RIGHT JOIN Operations", that seems to say the opposite:
NOTE: A LEFT JOIN or a RIGHT JOIN can be nested inside an INNER JOIN, but an INNER JOIN cannot be nested inside a LEFT JOIN or a RIGHT JOIN.
Furthermore the key here seems to be execution order. What determines whether the outer join or the inner join execute first. I thought that brackets should clearly resolve that but why does the following query fail:
SELECT *
FROM (F INNER JOIN H ON F.f1=H.h1) RIGHT JOIN G ON G.g3=F.f2;
Here the brackets should make the inner join get executed first, yielding all "good" fields, so that there should be no failure in the RIGHT JOIN. Yet it indeed fails. Why?
Furthermore if I change the above to a LEFT join, then it no longer fails.
Such is my understanding. However I don't understand the Access Help statement, under the topic of "LEFT JOIN, RIGHT JOIN Operations", that seems to say the opposite:
NOTE: A LEFT JOIN or a RIGHT JOIN can be nested inside an INNER JOIN, but an INNER JOIN cannot be nested inside a LEFT JOIN or a RIGHT JOIN.
Furthermore the key here seems to be execution order. What determines whether the outer join or the inner join execute first. I thought that brackets should clearly resolve that but why does the following query fail:
SELECT *
FROM (F INNER JOIN H ON F.f1=H.h1) RIGHT JOIN G ON G.g3=F.f2;
Here the brackets should make the inner join get executed first, yielding all "good" fields, so that there should be no failure in the RIGHT JOIN. Yet it indeed fails. Why?
Furthermore if I change the above to a LEFT join, then it no longer fails.