0
我想顯示兩個團隊的頭對頭勝利損失記錄,以顯示在遊戲結果頁面上。這是一場累積的比賽,在每場比賽之後競爭團隊將會改變。我需要定義'Team'和'Opponent'變量來運行查詢,但我似乎無法讓它工作。 $ GameID變量是通過GET方法傳遞的,但我需要將我的查詢的Team和Opponent變量設置爲特定GameID的團隊和對手。在mysql查詢中設置變量
SELECT @team := Team, @opponent := Opponent FROM MatchDetails2017 WHERE GameID = $GameID AND HA = 'H')
SELECT @Team, @Opponent,
COUNT(*) AS Played,
SUM(WL LIKE 'W%') AS Won,
SUM(WL LIKE 'L%') AS Lost,
SUM(WL = 'D') AS Drawn
FROM MatchDetails2017
WHERE Team = '@Team'
AND Opponent = '@Opponent'
AND GameID <= $GameID
");
我怎麼想補充一點到我上面的查詢? – waflfootyfacts
只需在此處添加更多詳細信息,樣本數據和預期結果。 –