我有以下关系,
想知道我怎样才能让球队成为比赛的赢家?
SELECT
m.id_match,
IF((id_home_team = ? AND score_home_team > score_away_team) OR
(id_away_team = ? AND score_home_team < score_away_team), 1, 0) AS won
FROM matches m
JOIN results r ON(r.id_match = m.id_match)
WHERE
id_home_team = ? OR id_away_team = ?
将 替换为?
您团队的 ID。
在SQL 小提琴中。