B
bill.peters
I have an access app. that links via ODBC to DB2 tables. My query takes
so long that it ends up timing out. I think I can speed it up by
optimizing the joins.
I'm trying to get all the records in table1 and all matching records in
table2, table 3, and table 4. When I set up the joins in the Design
View, then look at the SQL, it looks like it reads table1 at least
twice. Here is the code.
FROM (TABLE3 RIGHT JOIN (TABLE2 RIGHT JOIN TABLE1 ON TABLE2.A_SSN =
TABLE1.M_SSN) ON TABLE3.F_SSN = TABLE1.M_SSN) LEFT JOIN TABLE4 ON
TABLE1.M_SSN = TABLE4.R_SSN
It seems like I should be able to do something like:
FROM TABLE1
LEFT JOIN TABLE2 ON TABLE2.A_SSN = TABLE1.M_SSN
LEFT JOIN TABLE3 ON TABLE3.F_SSN = TABLE1.M_SSN
LEFT JOIN TABLE4 ON TABLE4.R_SSN = TABLE1.M_SSN
But that errors on me.
Any suggestions are appreciated. Thanks,
-Bill
so long that it ends up timing out. I think I can speed it up by
optimizing the joins.
I'm trying to get all the records in table1 and all matching records in
table2, table 3, and table 4. When I set up the joins in the Design
View, then look at the SQL, it looks like it reads table1 at least
twice. Here is the code.
FROM (TABLE3 RIGHT JOIN (TABLE2 RIGHT JOIN TABLE1 ON TABLE2.A_SSN =
TABLE1.M_SSN) ON TABLE3.F_SSN = TABLE1.M_SSN) LEFT JOIN TABLE4 ON
TABLE1.M_SSN = TABLE4.R_SSN
It seems like I should be able to do something like:
FROM TABLE1
LEFT JOIN TABLE2 ON TABLE2.A_SSN = TABLE1.M_SSN
LEFT JOIN TABLE3 ON TABLE3.F_SSN = TABLE1.M_SSN
LEFT JOIN TABLE4 ON TABLE4.R_SSN = TABLE1.M_SSN
But that errors on me.
Any suggestions are appreciated. Thanks,
-Bill