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:
SELECT DISTINCT(page_title) as title, count(page_title) AS count FROM page_title GROUP BY page_title 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.
Hello!
I am Blair Wadman and this where I share tutorials and trouble shooting guides.
My latest project is writing Master Drupal 7 Module Development, a book to help you conquer the sometimes baffling world of Drupal development.
You might like to sign up to my mailing list for tips on getting started with Drupal module development. Includes free Starting Drupal Module Development series (coming soon).
Master Drupal Module Development - 20% off
Sick of all the Googling? Climb the learning curve faster and start module developing today.
Currently 20% off!
Comments
Thanks its helped alot :)
Thanks its helped alot :)
Add new comment