Home » MySQL » Find Duplicate Rows Query

Here’s an SQL query that’ll return all the duplicate rows in your table.

SELECT `id`, COUNT(*) as `dup`
FROM `table_name`
GROUP BY `id`
HAVING `dup` > 1
ORDER BY `dup`

Leave a Reply

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