mystic coders

Find duplicate rows in a database using standard SQL

31 January, 2006 (00:15) | Java

Thanks goes to Xgc in #mysql on freenode for showing me this little one-liner. We needed to add a unique key to one of our tables, and a duplicate was in our midst. Enter this handy one-liner:

SELECT field1, count(*) FROM tbl1 GROUP BY field1 HAVING count(*)>1;

problem solved, a nice simple list of the duplicated rows in front of you.

Comments

Pingback from Something is going on » Find duplicate rows in a database using standard SQL
Date: January 31, 2006, 1:22 am

[…] Via kinabalu: SELECT field1, count(*) FROM tbl1 GROUP BY field1 HAVING count(*)>1;    […]

Write a comment





About mystic

Mystic is located in Southern California, we are a dedicated team of magic makers for your organizations needs. We can take your needs and turn them into the solution that fits perfectly for your company.
Learn More

 

Categories

Archive