Categories
Databases MySQL Quick Tips sql

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