SQL Delete duplicate data
This article provides a MySQL delete duplicate data, is the data table there are more than two duplicate data, delete the smallest number of a piece of information.
Delete ' Borough_name ' as a from Fke_borough as a,
(
Select *,min (ID) from Fke_borough GROUP BY ' Borough_name ' has count (1) > 1
) as B
where a. ' Borough_name ' = B. ' Borough_name ' and a.id > b.id;
SELECT COUNT (*)
From ' Fke_borough '//3423
SELECT * from ' Fke_borough ' GROUP BY ' Borough_name ' has count (' borough_name ') >1//repeat 591
Query duplicate record select * FROM table GROUP by name
Just show the repetition.
SELECT *, COUNT (*) as Nums from Tab_a Group by name has Nums>1
Method One: (This method is relatively good, only the self-added field will be rebuilt)
Create a new temporary table
CREATE TABLE tmp as SELECT * from Youtable GROUP by name
Delete the original table
drop table Youtable
Renaming tables
ALTER TABLE TMP rename Youtable