TL;DR: I want to know if it's possible to mix LEFT and INNER joins in Access, as LEFT joins are (as is to be expected) slowing my query down significantly.
Full version: Yesterday, I was having an issue that it turns out was caused by Access 2010 not liking me mixing LEFT and INNER JOINs in a combined query. A little recap here:
I had three queries, which I wished to combine. Each of the constituent queries was constructed using several tables and INNER JOINs.
I then needed to combine the three queries. Q1 contained more results than Q2 and Q3, and where there were no matches in Q2 and/or Q3, I still wanted to return the results from Q1. Similarly where Q2 returned a result Q3 didn't, I wanted to return null results rather than no results, and vice versa.
All of this necessitated a fourth query joining Q1, Q2, and Q3 using LEFT JOINs; but this caused a "multipart identifier cannot be bound" error. This was solved by replacing all of the INNER JOINs in the constituent queries with LEFT JOINS. Essentially, I'd assumed that Q4 would look only at the results of the other queries, whereas it was actually working it all out at once, hence the error.
So, I've solved the actual error, but I'm now running four queries, all using LEFT JOINs. Even though this is returning the same results in each of the constituent queries, it's much slower because of how outer joins work.
Is there any way that I can get my combination query to work as I'd originally expected (i.e. to produce Q1, Q2 and Q3 using INNER JOINS for speed, then have Q4 treat them as flat data when LEFT JOINing them)?
I could use some VBA to drop each of the queries into a temporary table and have Q4 look at those, but I was hoping to do it all in SQL. Can this be done?
SELECT ... FROM (SELECT INNER q1, q2 etc) LEFT Q3- Fionnuala