New answers tagged

0

Plan A: ALTER IGNORE TABLE users ADD UNIQUE(email, alt_email, mobile and alt_mobile); This will go through the table, copy it over, ignoring any dups. I am, however, hesitant to say that it will properly handle NULLs in those columns. Plan B: CREATE TABLE new LIKE users; ALTER TABLE new ADD UNIQUE(email, alt_email, mobile and alt_mobile); INSERT ...


2

Consider enforcing this combination of columns as a unique constraint at the database level. That won't be possible until the existing duplicates are cleaned out. But it will help prevent this problem from creeping back into the data. You should define the 4 columns as a non-unique index now since this process will involving lots of comparisons using them. ...



Top 50 recent answers are included