tanhaaiyaaN

Notes from the underground!

mysql – identifying number of duplicates in a table

Written By: tanhaa - Aug• 16•07

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

Share

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>