boring code

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, [...]