0

这是一个示例表:

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 列。我真的需要一些见解。

4

1 回答 1

3
SELECT COUNT(*)
FROM   games_table
WHERE  game_outcome = 'Home wins'
AND    (home_team = 'Chelsea' OR away_team = 'Chelsea')
于 2012-04-20T13:13:12.793 回答