With SQL statements, delete duplicates only keep one
In thousands of records, there are some same records, how can you use SQL statements, delete duplicates
1, look for redundant records in the table, duplicate records are based on a single field (Peopleid) to determine
Select *from peoplewhere peopleid in ( select Peopleid from people GROUP by Peopleid having 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
Deletefrom peoplewhere peoplename in ( SELECT peoplename from people GROUP by Peoplename have count (peoplename) > 1 ) and Peopleid not in ( SELECT min (peopleid) From people GROUP by peoplename have count (peoplename) > 1)
3. Find redundant duplicate records (multiple fields) in the table
Select *from vitae awhere (A.peopleid, A.seq) in ( select peopleid, seq from Vitae GROUP by Peopleid, seq has count (*) > 1 )
4. Delete extra duplicate records (multiple fields) in the table, leaving only the record with ROWID minimum
Deletefrom vitae awhere (A.peopleid, A.seq) in ( SELECT peopleid, seq from vitae GROUP by Peopleid, seq has count (*) > 1 ) and rowID not in ( SELECT min (rowid) C15/>from vitae GROUP by Peopleid, seq has count (*) > 1)
5. Find redundant duplicate records (multiple fields) in the table, not including the smallest ROWID records
Select *from vitae awhere (A.peopleid, A.seq) in ( select peopleid, seq from Vitae GROUP by Peopleid, seq has count (*) > 1 ) and rowID not in ( SELECT min (rowid ) from vitae GROUP by Peopleid, seq has count (*) > 1)
6. Remove the first bit to the left of a field:
UPDATE Tablenameset [title]= Right ([title], (Len ([title])-1) "WHERE title like ' Village% '
7. Remove the first bit to the right of a field:
UPDATE Tablenameset [title]= left ([title], (Len ([title])-1)) WHERE Title like '% Village '
8. False Delete extra duplicate records (multiple fields) in the table, not including ROWID minimum records
UPDATE vitaeset ispass =-1WHERE Peopleid in ( SELECT peopleid from vitae GROUP by Peopleid
Delete duplicate data in MySQL keep only one bar