G
Guest
I'm working with a 75,000 record database in Access. The problem of Duplicate
records has been going on for months and my task is to eliminate all
duplicates. I wrote a SQL querie that will search the "NAMES" table for
duplicates and write them to a seperate table. Works great ... only 18,000
duplicate records. :-/ Now I need to stop the entry of duplicate records. So
I need a query that will check a temperary table against the "NAMES" table
and stop dupes from being added to "NAMES" table.
I first need to look at FNAME field and compare duplicates against LNAME. If
there are two John Does, I then need to look at the ADD1 field to see if the
John Doe has the same address (if so the records are written to a "DUPE"
table) if address is different, I look at the EMAIL field. If there is a
duplicat John Doe with a duplicate email address, it is written to the "DUPE"
table.
The single table query looks like this:
INSERT INTO [Dupe]
SELECT NAMES.LNAME AS LNAME, NAMES.FNAME AS FNAME, NAMES.ADD1 AS ADD1,
NAMES.EMAIL AS EMAIL, NAMES.ID AS ID, NAMES.ENTRYDATE AS ENTRYDATE
FROM [NAMES]
WHERE ((([NAMES].[LNAME]) In (SELECT [LNAME] FROM [NAMES] As Tmp GROUP BY
[LNAME],[ADD1] HAVING Count(*)>1 And [ADD1] = [NAMES].[ADD1]))) AND
((([NAMES].[FNAME]) In (SELECT [FNAME] FROM [NAMES] As Tmp GROUP BY
[FNAME],[ADD1] HAVING Count(*)>1 And [ADD1] = [NAMES].[ADD1])))
ORDER BY NAMES.LNAME, NAMES.Add1;
How do I write something that compare 2 tables in the same manner?
records has been going on for months and my task is to eliminate all
duplicates. I wrote a SQL querie that will search the "NAMES" table for
duplicates and write them to a seperate table. Works great ... only 18,000
duplicate records. :-/ Now I need to stop the entry of duplicate records. So
I need a query that will check a temperary table against the "NAMES" table
and stop dupes from being added to "NAMES" table.
I first need to look at FNAME field and compare duplicates against LNAME. If
there are two John Does, I then need to look at the ADD1 field to see if the
John Doe has the same address (if so the records are written to a "DUPE"
table) if address is different, I look at the EMAIL field. If there is a
duplicat John Doe with a duplicate email address, it is written to the "DUPE"
table.
The single table query looks like this:
INSERT INTO [Dupe]
SELECT NAMES.LNAME AS LNAME, NAMES.FNAME AS FNAME, NAMES.ADD1 AS ADD1,
NAMES.EMAIL AS EMAIL, NAMES.ID AS ID, NAMES.ENTRYDATE AS ENTRYDATE
FROM [NAMES]
WHERE ((([NAMES].[LNAME]) In (SELECT [LNAME] FROM [NAMES] As Tmp GROUP BY
[LNAME],[ADD1] HAVING Count(*)>1 And [ADD1] = [NAMES].[ADD1]))) AND
((([NAMES].[FNAME]) In (SELECT [FNAME] FROM [NAMES] As Tmp GROUP BY
[FNAME],[ADD1] HAVING Count(*)>1 And [ADD1] = [NAMES].[ADD1])))
ORDER BY NAMES.LNAME, NAMES.Add1;
How do I write something that compare 2 tables in the same manner?