How does mysql delete duplicate records? mysql
The table name is tongxunlu. The field is id sXingMing sXingBie dtShengRi.
Because duplicate inserts and several copies of data are inserted, you want to delete duplicate
Reply to discussion (solution)
For example, how to judge duplicate.
Manually delete ..
You can directly determine whether the values of the sXingMing sXingBie dtShengRi fields are the same, and then delete them as needed.
Delete duplicate records
delete from tongxunlu a where rowid not in(select max(rowid) from tongxunlu where id=a.id and sXingMing=a.sXingMing and sXingBie=a. sXingBie and dtShengRi=a.dtShengRi);
delete from tongxunlu where id not in(select max(id) from tongxunlu group by id sXingMing sXingBie dtShengRi;
Groups the criteria for determining the repetition.
The number of data records.
If there is not much data, back up the data table and clear the original table. foreach scans the backup data table and inserts non-repeated data into the original table.
In this way, the problem is solved, and there is no need to make it so advanced.
Only a few pieces of data are deleted directly using a third-party tool.
Delete from tb1 where id in (select id, count (id) as tt from tb. where having tt> 1)
The execution must take a certain amount of time. The key is the amount of data.
Delete from tb1 where id in (select id, count (id) as tt from tb. where having tt> 1 group by $ fn)
Drop group
Learned
Technology Life