Find pesky duplicates in mysql

Posted by gturnbul on December 14, 2009 in boring code |

Let’s say you had an app that had a ton of users and were suspicious that there were pesky duplicates. Here is a quick mysql select to help put your mind at ease.


select username,count(*) as n
from users
group by username
having n > 1;

or search by first and last name:


select concat(firstname,' ',lastname) as name, count(*) as n
from users
group by name
having n > 1;

Write a Comment on Find pesky duplicates in mysql

Subscribe

Follow comments by subscribing to the Find pesky duplicates in mysql Comments RSS feed.