Count of duplicate values in MySQL table

A client is using the Drupal node title module and, as part of an SEO review, I want to see how many duplicate meta titles there are. The following is a simple MySQL statement that I ran to get the answer:

  1. SELECT DISTINCT(page_title) as title, count(page_title) AS count
  2. FROM page_title
  3. GROUP BY page_title
  4. HAVING count > 1

This will return a result like this:

title count
Buy a green widget 2
Buy a blue widget 3
About blue widgets 2

So in this case, the title "Buy a green widget" is used 2 times.

This is a good example of how to get a count of duplicate values for a MySQL table.

Enjoy this article?

Get my best content on Javascript, CSS, PHP & Git before anyone else and special bonuses.

Get started


Thanks its helped alot :)

thank you..this is realy help full

really helpful for a guy like me.

Hi this is great i just start working with your code i just got one question what happen to the other records that are only one record they are not shown, is there a way to add them too to the report like
name, counts
edi 3
tomate 12
love 1
to have all the info because single records are not shown,

thank you

Its worked!! Thanks

Add new comment