计算每个成员名称在 table 中出现的次数

Count the number of times each members name appears in a table with a condition

考虑以下 table:

我正在寻找一个查询:

-统计每个成员名字在tablewhere tournament= "EPL" AND round ="12"[=14中出现的次数=]

对于这个例子,查询应该return:

安德鲁 = 3 胜

约瑟夫 = 2 胜

约翰 = 1 胜

马丁 = 1 胜

我想过只使用一个简单的计数查询,如:

Select count(winning_member) as nrWins WHERE tournament="EPL" and round="12" and winning_member = '$mem_name' 

但这将导致我不得不遍历所有用户,这不是一个选项。

我完全陷入了这个问题...任何输入将不胜感激

尝试以下查询

SELECT count(*) as nrWins, winning_member WHERE tournament="EPL" and round="12" GROUP BY winning_member;

如果你真的想要你提到的确切输出,你可以试试这个

SELECT CONCAT(winning_member, ' = ', count(*), ' Wins')  
WHERE tournament="EPL" 
AND round="12" 
GROUP BY winning_member;