TecTao Posted January 16, 2015 Share Posted January 16, 2015 I need Delete Duplicate Email Records That Are Attached To One Account But Can Be Found In Multiple AccountsI have a table, consumer_mgmt. It collects consumer information from various forms. These forms are available through different pages that are part of a business package.A business can offer these signups to gather names and emails from consumers for various types of specials they may offer. So a consumer my be in the consumer_mgmt table 5, 10, 15 times for that particular business.But, that consumer may be in the consumer_mgmt table multiple times for a different business. So multiple times for multiple businesses.I need to remove duplicates for each business account so the consumer is only the consumer_mgmt only once for each business.There are approximately 15,000 rows currently in the consumer_mgmt table. I'm not sure where to begin on the logic. Since there are multiple business accounts that the emails are attached to, would one have to build a case for each loop? Quote Link to comment https://forums.phpfreaks.com/topic/293999-delete-duplicate-email-records-that-are-attached-to-one-account-but-can-be-found-in-multiple-accounts/ Share on other sites More sharing options...
Psycho Posted January 16, 2015 Share Posted January 16, 2015 Not enough information to really answer the question. Are there more details than the email address and company associated with these records? If there are two records for the same company and the same email address - what is the logic on which record to keep? They could have different data in the other fields. And what other fields ARE there? To do this we would likely need something such as a primary key field or a timestamp to ensure we delete all but one record. Quote Link to comment https://forums.phpfreaks.com/topic/293999-delete-duplicate-email-records-that-are-attached-to-one-account-but-can-be-found-in-multiple-accounts/#findComment-1503197 Share on other sites More sharing options...
TecTao Posted January 16, 2015 Author Share Posted January 16, 2015 Yes there are five other fields, three that are identifiers to the particular businesses. Two are categories of those businesses. These fields were added early on years ago but are not necessary to any applications. The consumer_mgmt table handles sending out various emails for different specials. So we are finding multiple emails going out to the same recipient that had been added multiple time. I just need to pare it down so that there is one customer email for one business. There is a field of the date of entry so if there were the need to identify which of the multiple emails should be removed, it could be the oldest. I see where you are going with this, how would the script decide which entry stays and which ones get deleted. Quote Link to comment https://forums.phpfreaks.com/topic/293999-delete-duplicate-email-records-that-are-attached-to-one-account-but-can-be-found-in-multiple-accounts/#findComment-1503203 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.