The table structure is as follows:
Mysql> desc tbl; + ------- + -------------- + ------ + ----- + --------- + ---------------- + | FIELD | type | null | key | default | extra | + ------- + -------------- + ------ + ----- + --------- + ---------------- + | id | bigint (20) | no | pri | null | auto_increment | word | varchar (255) | no |-| state | char (1) | no | I | + ------- + -------------- + ------ + ----- + --------- + ---------------- +
The statement for deleting duplicate records is as follows:
Delete T1 from TBL T1, TBL T2 where t1.word = t2.word and t1.id> t2.id;
The principle is that the TBL table itself performs Cartesian product with itself. If the word fields of the two records are the same, the record with a large Id field will be deleted. That is to say, for records with the same word field, only the one with the smallest Id field is retained, so as to delete the duplicate record ^_^