Question : Find Duplicate Query

Dear Experts,

I am building a database that is designed to find potential duplicates from another contact (non access) database.  In order to do this I have imported the records into Access into a table TBL-Master and built a Find Duplicates Query" using the wizard.  This works, but can only look up duplicates based on one field.

My criteria for determining a duplicate is a match in a persons email address.  The problem is that there are 2 fields for email addresses [email] and [email_2] & I would like to have the query look for duplicates across both field (i.e. a matching email address for Jo Bloggs may be found in 1 record in [email] and for another in [email_2]

The query statement Im currently using is as follows:

In (SELECT [email] FROM [TBL-Master] As Tmp GROUP BY [email],[email_2] HAVING Count(*)>1  And [email_2] = [TBL-Master].[email_2])

Can anyone help?

Answer : Find Duplicate Query

Use the following query. I have further tuned it and now I could run it in < 3 sec.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
SELECT A.email, A.email_2, A.firstname, A.lastname, A.people_ref, A.people_ref_no, A.name, A.title
FROM [TBL-Master] A, 
(
SELECT TMP 
FROM (SELECT TMP FROM (SELECT [email] AS TMP FROM [TBL-Master] where [email] is not null UNION ALL SELECT [email_2] AS TMP FROM [TBL-Master] where [email_2] is not null) AS TT GROUP BY TMP HAVING COUNT(*) > 1)
) AS B
WHERE
A.email = B.TMP
OR 
A.email_2 = B.TMP
ORDER BY A.email, A.email_2
Random Solutions  
 
programming4us programming4us