Hello, I am trying to find duplicate rows in my DB, like this:
SELECT email, COUNT(emailid) AS NumOccurrences FROM users GROUP BY emailid HAVING ( COUNT(emailid) > 1 )
This is ok, it returns me the emailid and the found matches. Now what I wanna do is to compare the ID column to another table I have and set a column there with the count.
The other table has a column duplicates which gets the amount of duplicates from the select. So lets say we have 3 rows with the same emailid, the duplicates column has a "3" in all 3 rows. What I want is a "2" in the first 2 and nothing or 0 in the last of the 3 matching ID rows.
Possible?
Thanks