View Full Version : Combine Data From 2 Tables - INNER JOIN???


nikomaxos
06-19-2009, 12:21 AM
Hello to the comunity!

This is my first post!

Here is my case,

I have 2 tables, T1 and T2, both having 2 columns. In the first column they both have a customer code. T2 has on column 2 the customer's account balance. I use the INNER JOIN and works almost fine. My problem is that when i run the query it only brings the records that exist in both T1 and T2. I need to have the ones from T1 that do not exist in T2 also.

Here is my syntax:

SELECT T1.field1, T1.field2
FROM T2 INNER JOIN T1 ON T2.field1 = T1.field1;

Is there any easy way to solve this? I'm in my first steps in Access, so easy solutions could be really helpfull

namliam
06-19-2009, 12:32 AM
Welcome to AWF

Use the query wizard to make an "Unmatched" query... that should give you what your looking for.

nikomaxos
06-19-2009, 12:55 AM
Yes, works fine, stil....

It only shows the unmatched records. Is there a way to combine those 2 querys? Or an other way to have them both in only one query?
I need a result like this:


(cust.code) (cust.name) (account balance)

T1.field1 T1.field2 T2.field2
5030 John Smith 300,00
4586 Alex Robes -2215,00
3694 Mark Holmes 3251,65
9578 Kate Mars (or 00,00)
6520 Nik Cage (or 00,00)
3625 Martin Jones 845,26


PS: Thanks for the fast reply!

namliam
06-19-2009, 01:04 AM
In the unmatched query you find in the criteria "Is null", to show only the unmatched.
Remove that and you will also get the matched

nikomaxos
06-19-2009, 01:13 AM
Thanks Again!

Really worked fine!

namliam
06-19-2009, 01:14 AM
This BTW is called an "outer join"