how can i write a query to list duplicate entries in a database from the same category. The duplicates have the same value in the "name" column. I need to list only the duplicates in the same category so I can then delete the duplicate.
I am using this example from a search
SELECT email FROM tableName GROUP BY email HAVING count(email) > 1
That works for getting duplicates but it gets all duplicates, how can i rewrite it to get the duplicates from the same categories. In the above example, if i have an email that exists in the cat 1 and cat 4, it will be shown as duplicate, which is not the case. It should only list duplicates if the email exists twice or more in cat 1, or twice and more in cat 4 and so on.
Thanks.