1, Query deduplication data
SELECT *, COUNT (distinct name) from the table group by name
2. Avoid duplication of data
If the uniqueness of a record is distinguished by a primary key primary or a unique index, it is possible to avoid duplicate insert records:
Insert ignore into table_name (EMAIL,PHONE,USER_ID) VALUES (' [email protected] ', ' 99999 ', ' 9999 '), so when there are repeated
The record will be ignored, after execution returns the number 0, there is another application is to copy the table, to avoid duplicate records:
3. Delete duplicate data and keep only one
DELETE From' Noid ' USING ' noid ',
(SELECT DISTINCT MIN(' ID ')As' id ', ' name ', 'Add`From' Noid 'GROUP By' Name ', 'Add`Having COUNT(1)> 1)As ' T2 '
WHERE ' noid '. ' name ' = ' t2 '. ' Name ' and ' noid '. 'add' = ' T2 '. 'add' and ' noid '. ' id ' <> ' T2 '. ' ID ';
MySQL Go heavy