Should be simple query - giving me heartache (1 Viewer)

outofpractice

Registered User.
Local time
Today, 04:26
Joined
May 10, 2011
Messages
32
I have which I thought would be an ultra-simple matter that is turning into nothing but trouble - I'm under a time constraint and am getting to the point where I have to look for assistance - so thought there was no better place than this forum.

Basically I pulled some data into an access database so I can query it and get the results I want.

I have two Tables:

Table1:

ID
Email Address
Custom ID

Table2:

Custom ID

--------

What I want to do is a query that brings back ID, Email Address, and Custom ID from Table1 when [Table1].[Custom ID]<>[Table2].[Custom ID]

All I am getting is thousands upon thousands of duplicate records. I've tried everything I can think of at this point and don't know what else to try.

I even tried running a match macro in Excel to identify where there was a match so I could then just delete the records - but there is so much data that Excel just chokes and gives "Not Responding"

I know I'm probably overlooking something obvious - but any help would be appreciated.

Again - all I want to do is return all records from Table 1 where the Custom ID doesn't match the Custom ID on Table 2

Thanks for any assistance
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 04:26
Joined
Aug 30, 2003
Messages
36,125
Does the unmatched query wizard get you the desired result?
 

Minty

AWF VIP
Local time
Today, 12:26
Joined
Jul 26, 2013
Messages
10,371
Use a Left Join to the null value;

Code:
SELECT Table2.CustomID, Table1.ID, Table1.[Email Address], Table1.CustomID
FROM Table1 LEFT JOIN Table2 ON Table1.CustomID = Table2.CustomID
WHERE Table2.CustomID Is Null ;
 

outofpractice

Registered User.
Local time
Today, 04:26
Joined
May 10, 2011
Messages
32
Use a Left Join to the null value;

Code:
SELECT Table2.CustomID, Table1.ID, Table1.[Email Address], Table1.CustomID
FROM Table1 LEFT JOIN Table2 ON Table1.CustomID = Table2.CustomID
WHERE Table2.CustomID Is Null ;

I think that this has worked - I'll have to spot check the results but it looks 100% better than what I had been receiving.

I can't think you enough!
 

outofpractice

Registered User.
Local time
Today, 04:26
Joined
May 10, 2011
Messages
32
Does the unmatched query wizard get you the desired result?

Thanks for the reply. This was a good idea as well - I always forget about the Query Wizard functions and just go into Query Design. I bet this would have easily worked - my own fault for overlooking this.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 04:26
Joined
Aug 30, 2003
Messages
36,125
The wizard would have created the same thing Minty posted, what's sometimes called a frustrated join.
 

Minty

AWF VIP
Local time
Today, 12:26
Joined
Jul 26, 2013
Messages
10,371
Pauls post and mine "Crossed" in the ether - I always forget about that wizard as well.

what's sometimes called a frustrated join.

Is that a euphemism for "Marriage"?
 

Users who are viewing this thread

Top Bottom