Edu’s quick notes

little asteroids here 
« Back to blog

Finding duplicate rows SQL

I needed to find all the users with duplicated phone numbers in the phone_number table (same phones have the same number and same country_id):

SELECT user_id, number, COUNT(*) FROM phone_numbers GROUP BY user_id, country_id, number 
HAVING COUNT(*) < 1;

Comments (1)

Sep 01, 2009
rechnungskauf said...
Sometimes it's the little things that make life so much easier, isn't it? :)

Leave a comment...

 
Got an account with one of these? Login here, or just enter your comment below.
Posterous-login    Connect    twitter