0

我正在开发一个足球联赛,其中球队是由计算机随机完成的。这个联盟对球员而不是球队进行排名。每个玩家得分取决于游戏的结果:

his team wins : player scores 3 point
his team wins >5 goals difference: player scores 4 points
his team draws: player scores 1 point
his team loses: player doesnt score

为了存储联赛数据,我在 mySQL InnoDB 中创建了这些表:

game (id)
player (num, name)
team (game.id, player.num, type)
goals (time, team.id, team.num, team.type)

type - 标识哪支球队是球员(CHAR“A”或“B”)

  • 我想根据上述规则检索分类,我应该如何在 mySQL 中编写查询?
  • 我避免存储可以计算的数据(良好做法),但我应该更改表结构吗?
4

1 回答 1

0
SUM(CASE WHEN a THEN 3
         WHEN b THEN 4
         WHEN c THEN 5
         WHEN d THEN 1
                ELSE 0 END) ttl
于 2013-01-25T14:20:28.677 回答