To delete duplicate elements in sql:

- First check if it's ok:

SELECT email, 
 COUNT(email) AS NumOccurrences
FROM users
GROUP BY email
HAVING ( COUNT(email) > 1 )
  1. Then delete
DELETE T1
FROM MyTable T1, MyTable T2
WHERE T1.dupField = T2.dupField
AND T1.uniqueField > T2.uniqueField
Enter your comment. Wiki syntax is allowed:
 
  • daily/delete_duplicates_sql.txt
  • Last modified: 2019/04/13 07:44
  • by admin