1
我正在製作一個小型足球預測網站,我需要的一項功能是從包含過去結果的數據庫生成排名表。我的數據庫有5列;生成總體排名表
Fixture_ID。
Home_team。
Away_team。
Htgoals(主隊進球數)。
Atgoals(客隊進球數)。
我有兩個疑問,在家裏玩,並從家裏
Home-" Select results.Home_team,
SUM(if(results.Htgoals > results.Atgoals,3,0)) AS W,
SUM(IF(results.Htgoals = results.Atgoals,1,0)) AS D,
SUM(IF(results.Htgoals < results.Atgoals,1,0)) AS L
from results
GROUP BY results.Home_team
order by W desc";
Away table-" Select results.Away_team,
SUM(if(results.Atgoals > results.Htgoals,3,0)) AS W,
SUM(IF(results.Atgoals = results.Htgoals,1,0)) AS D,
SUM(IF(results.Atgoals < results.Htgoals,1,0)) AS L
FROM results
GROUP BY results.Away_team
ORDER BY W DESC";
打客場時才返回排名表的球隊,我怎樣才能;
1.Do工會通過點的數量,而不是勝
的數量產生的總體排名表2.Rank隊
那麼你爲每場比賽輸入2行?我認爲你需要重新考慮數據模型。 –