MySQL delete duplicate records SQL statements and query duplicate records (1/4)

Source: Internet
Author: User
Tags mysql delete


Method 1
Delete yourtable
where [id] not in (
Select MAX ([id]) from yourtable
Group by (name + Valu) E)
Method 2
Delete a
from table a LEFT join (
Select (ID) from table GROUP by Name,value
) b on A.id=b.id
Where b.id is null
Query and delete duplicate records SQL statements
Query and delete duplicate records SQL statements
1, lookup table redundant records, duplicate records are based on a single field (Peopleid) to determine
SELECT * Fro M people
where Peopleid in (select Peopleid to People group by Peopleid have count (Peopleid) > 1)
2, delete table many Duplicate records, which are based on a single field (Peopleid), leaving only the rowid smallest record
Delete from people
where Peopleid in (select Peopleid from people GROUP BY Peopleid has count (Peopleid) > 1)
and rowID not in (select min (rowid) from people group by Peopleid Ha Ving Tsun count (peopleid) >1)
3, find redundant records in a table (multiple fields)
Select * from Vitae a
where (A.PEOPLEID,A.SEQ) in (select P Eopleid,seq from Vitae GROUP by Peopleid,seq having count (*) > 1)  

home 1 2 3 4 last page
Related Article

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: info-contact@alibabacloud.com 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.