> I guess I wasn't clear - -I want all records. I have one table with hours
> worked and another with hours collected, but sometimes (I'm cash basis), the
[quoted text clipped - 5 lines]
> year 3 collected -- match worked
> no match collected -- year 4 worked.
I forgot to include a link to other DB design resources. Here it is:
http://home.bendbroadband.com/conradsystems/accessjunkie/resources.html#Database
Design101
Tom Wickerath
Microsoft Access MVP
http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
They represent ROWS, not fields. It is possible that in table 1 the row for
year1 doesn't exist, and it is possible that in table 2 the row for year5
doesn't exist, but what I want is a query where to output looks like my
example
TABLE 1 -billed TABLE
2 -- collected
1999 5 hrs
2000 6 hrs
2000 5 hours
2001 7 hrs
2001 6 hours
2002 9 hrs
2002 5 hours
2003 9 hrs
2003 11 hours
2004 1 hrs
2004 9 hours
2005 6 hrs
2005 3 hrs
2006 7 hrs
2006 9 hrs
2007 1 hrs
Other fields are products -- so in 1999 we may have collected on a product
that we stopped selling in 1998 -- in 2007 we have billed but haven't
collected anything yet.
Just understand that it is possible for table 1 to have rows that table 2
doesn't have and table 2 to have rows that table 1 doesn't have, but I want
them all. Would a left join and a right join on the same fields (year)
work?
> Hi Rich,
>
[quoted text clipped - 47 lines]
>> year 3 collected -- match worked
>> no match collected -- year 4 worked.
Tom Wickerath - 26 Feb 2007 04:24 GMT
Hi Rich,
> Just understand that it is possible for table 1 to have rows that table 2
> doesn't have and table 2 to have rows that table 1 doesn't have, but I want
> them all. Would a left join and a right join on the same fields (year)
> work?
Okay, I think I see what you need. Use the Find Unmatched Query wizard to
create a query that finds all records present in Table1 that are not present
in Table2. Create another (similar) query that finds all records in Table2
that are not present in Table1. You will need to have a suitable key field
that can uniquely identify the records in each table, and a means of joining
the two tables. After you have your two unmatched queries working properly,
copy their SQL statements and use these as the basis for a new union query.
You will union the results of each unmatched query.
Perhaps I can help a bit more if you identify the exact table names, field
names and data types of each field. For example:
tblCustomers
CustomerID Autonumber PK (primary key)
CustFirstName Text
CustLastName Text
etc.
Then give some sample data, but try to prevent the word wrap that was
present in the example that you just posted. It makes it kind of difficult to
see what is going on if the text wraps.
Tom Wickerath
Microsoft Access MVP
http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
> They represent ROWS, not fields. It is possible that in table 1 the row for
> year1 doesn't exist, and it is possible that in table 2 the row for year5
[quoted text clipped - 29 lines]
> them all. Would a left join and a right join on the same fields (year)
> work?
Van T. Dinh - 26 Feb 2007 04:25 GMT
I think you need what we normally call "Full Outer Join". Unfortunately,
JET doesn't support Full Out Join ...
You need to simulate the Full Outer Join by unioning 2 simple Outer Join
queries like:
========
SELECT T1.BilledYear, T1.BilledAmount, T2.CollectedAmount
FROM Table1 AS T1 LEFT JOIN
Table2 AS T2 ON T1.BilledYear = T2.CollectedYear
UNION
SELECT T2.CollectedYear, T1.BilledAmount, T2.CollectedAmount
FROM Table1 AS T1 RIGHT JOIN
Table2 AS T2 ON T1.BilledYear = T2.CollectedYear
========

Signature
HTH
Van T. Dinh
MVP (Access)
> They represent ROWS, not fields. It is possible that in table 1 the row
> for year1 doesn't exist, and it is possible that in table 2 the row for
[quoted text clipped - 78 lines]
>>> year 3 collected -- match worked
>>> no match collected -- year 4 worked.