Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

May 152010

Find duplicated records in MySQL


Assume you have a table `my_table` which contains a column called "name", how do you find what name has been duplicated in your table?

SELECT name, COUNT(`name`) as cnt
FROM `my_table`
GROUP BY `name`
HAVING cnt > 1

That's all.

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>