Reputation: 1552
Here's an example table:
games_table
----------------------------------------------------
| home_team | away_team | game_outcome |
----------------------------------------------------
| Chelsea | Arsenal | Home wins |
----------------------------------------------------
| Everton | Liverpool | Away wins |
----------------------------------------------------
| Arsenal | Chelsea | Home wins |
----------------------------------------------------
What I need is the number of times 'Chelsea' appears WHERE game_outcome = 'Home wins'
which is 2 in this example.
Normally this would be very easy but I'm stuck because I have to search 2 columns. I really need some insight.
Upvotes: 0
Views: 100
Reputation: 14457
SELECT COUNT(*)
FROM games_table
WHERE game_outcome = 'Home wins'
AND (home_team = 'Chelsea' OR away_team = 'Chelsea')
Upvotes: 3