J
JimJ
I'm finding in Access 2003 SP2 that, when I do a left outer join, a
calculated field in the right query is propagated to all records in
the outer join, not just those in common with the right table.
Here is the setup:
Table "T1" has just one field. The field is named "Well" and has
entries of "A", "B", "C", and "D".
Query "Q1_Select" adds a calculated field to selected records from
Table "T1":
SELECT T1.Well, "Hi" AS Flag
FROM T1
WHERE (((T1.Well) Between "A" And "B"));
The result, as expected, is:
Well Flag
---- ----
A Hi
B Hi
Query "Q2_fromQ1" does an outer join to include all records of Table
T1 and the matching records from Query "Q1_Select":
SELECT T1.Well, Q1_Select.Well, Q1_Select.Flag
FROM T1 LEFT JOIN Q1_Select ON T1.Well = Q1_Select.Well;
The result is:
T1.Well Q1_Select.Well Flag
------- -------------- ----
A A Hi
B B Hi
C Hi
D Hi
The "Flag" is added to the records that did not come from "Q1_Select".
This was not expected.
This experiment was repeated using a table instead of a query on the
right side of the join. This produced the expected result of:
T1.Well Q1_Select.Well Flag
------- -------------- ----
A A Hi
B B Hi
C
D
So what is going on here? Is there a workaround?
Any help would be appreciated,
JRJ
calculated field in the right query is propagated to all records in
the outer join, not just those in common with the right table.
Here is the setup:
Table "T1" has just one field. The field is named "Well" and has
entries of "A", "B", "C", and "D".
Query "Q1_Select" adds a calculated field to selected records from
Table "T1":
SELECT T1.Well, "Hi" AS Flag
FROM T1
WHERE (((T1.Well) Between "A" And "B"));
The result, as expected, is:
Well Flag
---- ----
A Hi
B Hi
Query "Q2_fromQ1" does an outer join to include all records of Table
T1 and the matching records from Query "Q1_Select":
SELECT T1.Well, Q1_Select.Well, Q1_Select.Flag
FROM T1 LEFT JOIN Q1_Select ON T1.Well = Q1_Select.Well;
The result is:
T1.Well Q1_Select.Well Flag
------- -------------- ----
A A Hi
B B Hi
C Hi
D Hi
The "Flag" is added to the records that did not come from "Q1_Select".
This was not expected.
This experiment was repeated using a table instead of a query on the
right side of the join. This produced the expected result of:
T1.Well Q1_Select.Well Flag
------- -------------- ----
A A Hi
B B Hi
C
D
So what is going on here? Is there a workaround?
Any help would be appreciated,
JRJ