SQL for Finding Duplicate Values

Quick post to remind me how to check a table column for duplicate values next time I’m looking for it (when my memory fails!)

1
2
3
4
SELECT id, count(id)
FROM mytable
GROUP BY id
HAVING count(id) > 1

Comments