It's unclear exactly what you want to do, so here's two possibilities.
If you want to determine how many times the same name
and food
combination occurs, you can use GROUP BY
to group like records and COUNT
to determine how many there are in the group:
SELECT name, food, COUNT(*) AS count
FROM your_table_name
GROUP BY name, food
Alternately, if you want to retrieve how many times only the name duplicates, you'll need a subquery:
SELECT name, food,
(
SELECT COUNT(*)
FROM your_table_name
WHERE name = table_alias.name
) AS count
FROM your_table_name AS table_alias
The first query will return only one row per name
/food
group, along with the count of how many records appear in the group. The second query will return all rows, with a count of how many rows have the same name in each row.