Cleaning duplicate records with SQL

I needed a way to clean out a MySQL table of records with duplicate email addresses. To do this I used a simple SELECT query inside of an INSERT.

INSERT INTO
    good_users(email)
        SELECT
            DISTINCT(email)
        FROM
            bad_users

Published by

Adam

Speaker, author, consultant, OSS contributor, SoFloPHP UG and SunshinePHP Conf organizer, RunGeekRadio Host, Long distance runner and ultra marathoner.

Leave a Reply

Your email address will not be published. Required fields are marked *