Programming / SQL · 2010-07-08

Finding Duplicate Records In Database

SELECT COL_TO_CHECK, COUNT(COL_TO_CHECK)
FROM table1
GROUP BY COL_TO_CHECK
HAVING COUNT(*) > 1
ORDER BY COUNT(*)

If there is more than 1 column with that value it will show up like:

COL_TO_CHECK               COUNT(COL_TO_CHECK)
-------------------------------------------------------------
Value                             3
Value2                            2
Value99                           4