Delete duplicates AND update fields

lehcarrodan

Registered User.
Local time
Yesterday, 19:03
Joined
Feb 20, 2017
Messages
11
Thought it would be easy with the query wizard.. Not so much.

So I have a whole lot of customers in tblCustomers
Problem is I imported from our old database so some data is duplicated so to start clean I want to delete duplicates.
BUT I want to store the CustomerNotes field of the duplicate entries all in one

EX.
CustID Name LastN CustNotes
CustID1 John Jacob abc
CustID2 John Jacob def
CustID3 John Jacob klsdhlh

WHAT I WANT TO KEEP
CustID Name LastN CustNotes
CustID1 John Jacob abc def klsdhlh


It comes up with 30,000 duplicates with the query wizard.
Any ideas??? Thank youuu
 
its not Delete and Update, its
Update then Delete.

there are two process to make

1. Update the CustomerNotes field.
to update your field, try the ConCatRelated()
function to gather all CustomerNotes for a
single customer. you can search it on this
forum or on the net

2. Delete Duplicates:
the query should look like this:

DELETE (SELECT COUNT(*) FROM yourTable AS T1 WHERE (T1.CustomerID = yourTable.CustomerID)) AS Expr1, *
FROM yourTable
WHERE (SELECT COUNT(*) FROM yourTable AS T1 WHERE (T1.CustomerID = yourTable.CustomerID))>1;

*****************
REMEMBER:
backup your table first before doing Delete Query.
this action is undoable.

also change "yourTable" with the correct table name
from the query i gave you.
 
Thanks, you guys are awesome.
I will be working on this Monday but I think you've given me a pretty good idea.
 

Users who are viewing this thread

Back
Top Bottom