我有兩個表,一個包含團隊列表,另一個包含這些團隊的計劃列表和得分結果。我希望在向排定表格中插入一行時能夠更新小組表格。因此,例如,如果我有:有關兩個表與功能的Mysql
Teams table
Team1
Team2
。
Schedules table
team1, 3
team2, 1
什麼,我希望能夠做的就是當比分字段更新我需要更新球隊表不同的領域。所以,當我更新此時間表排,
它會插入3成排的TEAM1之一,1爲TEAM2
此外,我想能夠計算的分數之間的差異,還插入這成隊表。
什麼是最好的實施方式?
我需要一個函數才能比較分數嗎?
謝謝,
到目前爲止,我想到做這樣的事情。
update table teams set teams.gamesplayed = teams.gameplayed +1 /*this would add one to the games played field because they just played.*/
然後爲進球像
update teams set teams.gf =
(
select t.goalsscored
from schedule t, teams s
where t.teamname = s.team1name AND)
)
那麼,你到目前爲止有什麼? – Norse 2012-04-06 05:31:19