MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Robert A. Rosenberg Date:July 11 2004 2:05am
Subject:RE: Weeding out duplicates
View as plain text  
At 10:25 -0600 on 07/09/2004, Jonathan Duncan wrote about Re: Weeding 
out duplicates:

>Lachlan,
>
>I want to identify the entries in the table where the email addresses
>are the same as another entry.  Whatever else is in the record does not
>matter to me.
>
>However, a second requirement for the query is that it show me the last
>duplicate instead of the first.  This way I keep the first entries and
>remove subsequent ones.
>
>Thanks,
>Jonathan Duncan

If you are willing to go with a PHP/MySQL solution as opposed to a 
pure MySQL one, try this:

  1) Use that query to get a list of what Email Addresses are duplicated.
  2) Now do a query with a WHERE Email=Duplicate-Email-Address and 
fetch the Primary Key.
  3) Do a Delete by Primary Key for all rows fetched in 2 EXCEPT for 
those keys fetched in 1.

The sequence is that you do step 1, loop though the results one at a 
time (step 2) doing step 3 in that loop.
Thread
Weeding out duplicatesJonathan Duncan8 Jul
  • RE: Weeding out duplicatesLachlan Mulcahy9 Jul
Re: Weeding out duplicatesjeffrey_n_Dyke9 Jul
Re: Weeding out duplicatesJonathan Duncan9 Jul
RE: Weeding out duplicatesJonathan Duncan9 Jul
  • RE: Weeding out duplicatesRobert A. Rosenberg11 Jul
RE: Weeding out duplicatesJonathan Duncan10 Jul
  • RE: Weeding out duplicatesRobert A. Rosenberg11 Jul
RE: Weeding out duplicatesJonathan Duncan12 Jul
RE: Weeding out duplicatesSGreen14 Jul