February 8, 2011

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!)

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

© Michael Sharman 2017