MySQL view duplicate data and delete

Note: The conditions can not be written, combined with the actual situation.

 

1. View the number of occurrences of duplicate data

select field, count(0) as number of occurrences from table name where condition group by field having count(field)>1

 

2. Delete duplicate data

delete from table name where condition field in (
select * from (
 select field from table name where condition group by field having count(field)> 1) a)

Guess you like

Origin blog.csdn.net/qq_36138652/article/details/115086155