Find Duplicate Rows in Table


/ Published in: SQL
Save to your folder(s)

Field1 + Field2 + Field3 should create 1 entry for each unique row in the DB. In an employee table, this would be FirstName + LastName + EmployeeNumber


Copy this code and paste it in your HTML
  1. SELECT * FROM TABLE WHERE field1 + field2 + field3 IN
  2. (
  3. SELECT field1 + field2 + field3 FROM TABLE GROUP BY field1 + field2 + field3 HAVING COUNT(*) > 1
  4. )
  5. AND uniqueID NOT IN
  6. (
  7. SELECT MAX(uniqueID) FROM xer_regis_new GROUP BY field1 + field2 + field3 HAVING COUNT(*) > 1
  8. )

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.