delete duplicated records mysql

# Changing the table ALTER IGNORE TABLE User ADD UNIQUE INDEX idx_name (Email); # Without change the table ## Keep the record with lowest id DELETE n1 FROM table t1, table t2 WHERE t1.id > t2.id AND t1.name = t2.name; ## Keep the record with highest id DELETE n1 FROM table t1, table t2 WHERE t1.id < t2.id AND t1.name = t2.name;;

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.