How does mysql delete duplicate records

Source: Internet
Author: User
Tags mysql delete

The table name is the Tongxunlu field is the ID sxingming sxingbie Dtshengri
Because repeatedly inserted, several data, want to delete duplicate

Reply to discussion (solution)

For example, how to judge the repetition.

Delete manually:

You can directly Judge Sxingming Sxingbie dtshengri These field values are the same, and then delete as needed

Delete duplicate records

Delete from Tongxunlu a where  rowid not in (select Max (ROWID) from Tongxunlu where and sxingming=a.sxingming an D  

Delete from Tongxunlu  where ID is not in  (the Select Max (ID) from the Tongxunlu Group by ID sxingming Sxingbie Dtshengri;

What to do with the criteria for judging the duplicates.

Say how many data first.
Data is not much, back up the data table, the original table empty, foreach sweep back up the data table, the non-duplicated inserted into the original table.
This will solve the problem, there is no need to engage in such a profound.

Only a few data, with third-party tools directly deleted.

Delete from tb1 where ID in (select Id,count (ID) as TT from Tb.where have tt>1)
Implementation must take a certain amount of time, the key to see how much data

Delete from tb1 where ID in (select Id,count (ID) as TT from Tb.where have tt>1 GROUP by $FN)
Dropped the group by

Study the

Flying Mood Technology Life

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.