2014-02-12 57 views
-1

有人可以幫我嗎?我有兩個表格,我會統計出現在10個「event_id」列中的行數。phpMYADMIN代碼來計算行

我有這樣的代碼,但不工作...

SELECT COUNT(event_id) FROM wp_leagueengine_season_matches_events, wp_leagueengine_tournament_matches_attributes WHERE event_id = '10' 

感謝您的關注

+2

需要分別計算這兩個表,或加入他們在一些匹配的列上。如果沒有它所屬的表,你不能引用'event_id'。 –

回答

1

讓我們試試這個

SELECT COUNT(wpe.event_id) as nr_wpe, COUNT(wpa.event_id) as nr_wpa 
FROM wp_leagueengine_season_matches_events wpe 
INNER JOIN wp_leagueengine_tournament_matches_attributes wpa 
    ON nr=nr_wpe+nr_wpa 
WHERE event_id = 10