E
enders
Access left joins returns incorrect rows on views (queries) with
manual created columns
Steps to reproduce
Create a table 'Table1' with the following fields
Field1 number
Field2 number
Field3 number
Value1 text
Enter the following values
1,1,1,a
1,1,2,b
1,2,1,c
1,2,2,d
2,2,2,e
3,3,3,f
(6 rows)
Create a table 'Table2' with the following fields
Field1 number
Field2 number
Field3 number
Value2 text
Enter the following values
1,1,1,x
(1 row)
Create the following query 'Query1'
SELECT
table1.*,
table2.value2
FROM
Table1 LEFT JOIN Table2 ON
(Table1.field3 = Table2.field3) AND
(Table1.field2 = Table2.field2) AND
(Table1.field1 = Table2.field1);
This will return 6 rows with an x on the row 1,1,1,a,x
(all rows from table1 combined with rows that match from table2)
Create the following query 'Query2'
SELECT
1 as field1,
Table2.field2,
Table2.field3,
Table2.value2
FROM
Table2;
This query will return only one row. The same as table2
Notice the 1 value as field1
And create the following query 'Query3'
SELECT
Table1.*,
Query2.Value2
FROM
Table1 left JOIN Query2 ON
(Table1.field1 = Query2.field1) AND
(Table1.field2 = Query2.field2) AND
(Table1.field3 = Query2.field3);
This should mean give me all rows from table1 and a value2 from query2
if possible.
And this query returns 4 rows !!!!!!!
If you dump the result into a table3 (Query4)
SELECT * into table3 FROM Query2;
And then create a the following query (Query5)
SELECT
table1.*,
table3.value2
FROM
Table1 LEFT JOIN Table3 ON
Table1.field1 = Table3.field1 AND
Table1.field2 = Table3.field2 AND
Table1.field3 = Table3.field3;
You got the 6 rows back.
I have run the same thing on SQL2000 and I get 6 rows back for query3
I have run this on Access 97 and Access 2002 and I get 4 rows
My Question : is this a bug in Access ?
With regards,
Constantijn Enders
manual created columns
Steps to reproduce
Create a table 'Table1' with the following fields
Field1 number
Field2 number
Field3 number
Value1 text
Enter the following values
1,1,1,a
1,1,2,b
1,2,1,c
1,2,2,d
2,2,2,e
3,3,3,f
(6 rows)
Create a table 'Table2' with the following fields
Field1 number
Field2 number
Field3 number
Value2 text
Enter the following values
1,1,1,x
(1 row)
Create the following query 'Query1'
SELECT
table1.*,
table2.value2
FROM
Table1 LEFT JOIN Table2 ON
(Table1.field3 = Table2.field3) AND
(Table1.field2 = Table2.field2) AND
(Table1.field1 = Table2.field1);
This will return 6 rows with an x on the row 1,1,1,a,x
(all rows from table1 combined with rows that match from table2)
Create the following query 'Query2'
SELECT
1 as field1,
Table2.field2,
Table2.field3,
Table2.value2
FROM
Table2;
This query will return only one row. The same as table2
Notice the 1 value as field1
And create the following query 'Query3'
SELECT
Table1.*,
Query2.Value2
FROM
Table1 left JOIN Query2 ON
(Table1.field1 = Query2.field1) AND
(Table1.field2 = Query2.field2) AND
(Table1.field3 = Query2.field3);
This should mean give me all rows from table1 and a value2 from query2
if possible.
And this query returns 4 rows !!!!!!!
If you dump the result into a table3 (Query4)
SELECT * into table3 FROM Query2;
And then create a the following query (Query5)
SELECT
table1.*,
table3.value2
FROM
Table1 LEFT JOIN Table3 ON
Table1.field1 = Table3.field1 AND
Table1.field2 = Table3.field2 AND
Table1.field3 = Table3.field3;
You got the 6 rows back.
I have run the same thing on SQL2000 and I get 6 rows back for query3
I have run this on Access 97 and Access 2002 and I get 4 rows
My Question : is this a bug in Access ?
With regards,
Constantijn Enders