如何計算event_participants表中的參與者人數。這是我的表如何計算左連接查詢
event_place
id | name
1 | New York
2 | Canada
event_participants
id | event_place_id | name
1 | 1 | Jon
2 | 1 | Mike
3 | 2 | Van
,我對我的查詢
SELECT count(*) as count
FROM event_participants as t1
LEFT JOIN event_place as t2
ON t1.event_place_id = t2.id;
得到一個錯誤的結果,結果是3
我應該得到的結果是這樣
New York | 2
Canada | 1
研究通過 –
組你可以使用'GROUP BY' [鏈接] (https://www.w3schools.com/sql/sql_groupby.asp) –