Category: sql

  • Finding Duplicates using SQL

    While migrating old data to a new database schema I was unable to activate a PRIMARY KEY on the legacy_customer_id field because there were duplicates. It turned out that the old application did not clean the data really well, and it allowed duplicates to be created where one of the customer_ids had a space character […]

  • 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