SELECT * FROM Hengtu_demandpush a
where (A.did,a.mid) in (select Did,mid from Hengtu_demandpush GROUP by Did,mid have count (*) > 1)
Or
SELECT * FROM Hengtu_demandpush GROUP by Did,mid have Count (*) >1
1, look for redundant records in the table, duplicate records are based on a single field (Peopleid) to determine
- SELECT * from People
- where Peopleid in (select Peopleid from People GROUP by Peopleid have Count (Peopleid) > 1)
2, delete redundant records in the table, duplicate records are based on a single field (Peopleid) to judge, leaving only the smallest ROWID records
- Delete from people
- where Peopleid in (select Peopleid from People GROUP by Peopleid have Count (Peopleid) > 1)
- and rowID not in (select min (rowid) from people GROUP by Peopleid have Count (Peopleid)>1)
3. Find redundant duplicate records (multiple fields) in the table
- SELECT * FROM Vitae a
- where (A.PEOPLEID,A.SEQ) in (select Peopleid,seq from Vitae GROUP by PEOPLEID,SEQ have Count (*) > 1)
4. Delete extra duplicate records (multiple fields) in the table, leaving only the record with ROWID minimum
- Delete from Vitae a
- where (A.PEOPLEID,A.SEQ) in (select Peopleid,seq from Vitae GROUP by PEOPLEID,SEQ have Count (*) > 1)
- and rowID not in (select min (rowid) from Vitae GROUP by PEOPLEID,SEQ have Count (*)>1)
5. Find redundant duplicate records (multiple fields) in the table, not including the smallest ROWID records
- SELECT * FROM Vitae a
- where (A.PEOPLEID,A.SEQ) in (select Peopleid,seq from Vitae GROUP by PEOPLEID,SEQ have Count (*) > 1)
- and rowID not in (select min (rowid) from Vitae GROUP by PEOPLEID,SEQ have Count (*)>1)
How MySQL queries duplicate records