mysql – identifying number of duplicates in a table


So my little query adventures with mySQL continues. Here’s another unique problem: There are duplicates in the table as there is no field that was setup as primary index. So how do we know how many do we have?

Well assume that the duplicate values happen on the “Phone Number” of the client. Here’s the query you would run:
select `BUSINESS PHONE`, count(*) as ‘Num of Dups’
from mytable
group by `BUSINESS PHONE`
having count(*) > 1


Leave a Reply

Your email address will not be published. Required fields are marked *