1. Use the insert ignore into statement to re-
Mysql> INSERTIGNORE intoperson_tbl (last_name, first_name) - VALUES('J','T'); Query OK,1Row affected (0.00sec) MySQL> INSERTIGNORE intoperson_tbl (last_name, first_name) - VALUES('J','T'); Query OK,0Rows Affected (0.00Sec
2. Query filtering Duplicate data
①. Using the MySQL keyword distinct to remove weight
MySQL>SELECTDISTINCT last_name, first_name from Person_tbl;
②. Using GROUP by to carry out the heavy
MySQL>SELECT last_name, first_name from person_tbl - GROUP by (last_name, first_name);
3. Delete duplicate data from a table
Idea: first create a temporary table, the non-duplicated data in the temporary table, and then delete the original table, and then rename the temporary table into a formal table
MySQL>CREATETABLESELECT from person_tbl GROUPby (last_name, first_name, sex); MySQL>DROPTABLE person_tbl; MySQL>ALTERTABLE to Person_tbl;
When MySQL inserts data, it removes duplicate data;