mysql count duplicates

SELECT name, food, COUNT(food) AS cnt
FROM table
GROUP BY name, food
HAVING (cnt > 1)

If you want the count of everything, not just the tuples with duplicates, then eliminate the HAVING line, as that’ll filter out anything that doesn’t have duplicates.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)