Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

query with criterium 'where not' 1

Status
Not open for further replies.

Pampers

Technical User
Apr 7, 2004
1,300
AN
Hi Everyone,
I have to tables, tblClients2006 and tblClients. I want make a query that selects all Clients from tblClients except those who are in tblClients2006

Pampers [afro]
Keeping it simple can be complicated
 
you want to use a left join, and filter for only records without a match on the right side. Just replace SomeKey with whatever you can use to compare the two tables:

Code:
select a.*
from tblClients a
left join tblClients2006 b
on a.SomeKey = b.SomeKey
where b.SomeKey is null

HOpe it helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
Tnx AlexCuse,

That works. And the I tried:

Code:
SELECT SYSADM_DEBITEUR.ZOEKNAAM, SYSADM_DEBITEUR.CDRELATIE, tblKlanten2006.CDRELATIE
FROM tblKlanten2006 RIGHT JOIN SYSADM_DEBITEUR ON tblKlanten2006.CDRELATIE = SYSADM_DEBITEUR.CDRELATIE
WHERE (((tblKlanten2006.CDRELATIE) Is Null));

Which looks like it is working also...


Pampers [afro]
Keeping it simple can be complicated
 
What is NOT so working today is my head. Thanx AlexCuse, things are coming back to me again...

Pampers [afro]
Keeping it simple can be complicated
 
Yup, right and left joins are really the same thing, but just have the tables sitting on different sides of the join. I just always use left, because it keeps things simple (which like you say, can be very complicated ;-) )

I'm glad you got it working!

Alex

Ignorance of certain subjects is a great part of wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top