这是一个示例表:
games_table
----------------------------------------------------
| home_team | away_team | game_outcome |
----------------------------------------------------
| Chelsea | Arsenal | Home wins |
----------------------------------------------------
| Everton | Liverpool | Away wins |
----------------------------------------------------
| Arsenal | Chelsea | Home wins |
----------------------------------------------------
我需要的是'切尔西'出现的次数WHERE game_outcome = 'Home wins'
,在这个例子中是2。
通常情况下这很容易但是因为我必须搜索2列而被卡住了。 我真的需要一些见解。
答案 0 :(得分:3)
SELECT COUNT(*)
FROM games_table
WHERE game_outcome = 'Home wins'
AND (home_team = 'Chelsea' OR away_team = 'Chelsea')