By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,673 Members | 1,221 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,673 IT Pros & Developers. It's quick & easy.

Merging/Deleting Duplicate User Records

P: 1
I am attempting to clean up some data for migration to a new system, and I am stuck on dealing with duplicated user records. The following fields in tblUser are germane to the problem:

UserID: primary key for the table tblUser
UserEmail: the field I am searching for duplicates on
UserLastLogin: the last time
review_count: the number of records in the linked table tblReview

What I would like to do is (in pseudo-code):

FOR EACH pair of records with matching UserEmail values:
IF oldest UserLastLogin review_count = 0
DELETE record with oldest UserLastLogin

IF ELSE oldest UserLastLogin review_count > 0
SET review IDs for oldest UserLastLogin to newest UserLastLogin in tblReview
DELETE record with oldest UserLastLogin

I am stuck trying to do this with queries and know nothing of using VBA to do it, so any pointers in either direction would be very helpful.
May 25 '07 #1
Share this Question
Share on Google+
1 Reply

puppydogbuddy
Expert 100+
P: 1,923
The following link is a "How To" step by step. The only difference between what you want to do and the link is that the records retained are the oldest, and you want to retain the latest. The only change you have to make in the procedure is to replace the word "First" with the word "Last" in the query so that the query results contain the last (most recent) records.

Deleting Duplicate Records Leaving Just the First
May 25 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.