This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Assume `Table` has 4 columns: id, col1, col2, col3 | |
CREATE TABLE `dups` ( | |
`id` int(10) unsigned DEFAULT NULL, | |
`hash` varbinary(32) DEFAULT NULL, | |
KEY `id` (`id`), | |
KEY `hash` (`hash`) | |
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | |
INSERT INTO dups SELECT MIN(id) AS id, MD5(CONCAT(col1, col2, col3)) AS hash FROM `Table` GROUP BY col1, col2, col3 HAVING COUNT(*) > 1; |
NewerOlder