Tuesday, June 9, 2009

Find Duplicate IDs in a Table with SQL

This is a simple way to find all the rows that have duplicate IDs / values in a table.

SELECT entryid, Count(entryid) AS ecount
FROM filelocation
GROUP BY entryid
HAVING (Count(entryid) > 1) -- This runs after the aggregate count() function

No comments: