`game_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '比赛id',
  `game_type` int(3) unsigned NOT NULL DEFAULT '0' COMMENT '比赛类型',
  `home_team` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '主队球队id',
  `home_score` int(11) unsigned DEFAULT '0' COMMENT '主队得分',
  `away_score` int(11) unsigned DEFAULT '0' COMMENT '客队得分',
  `away_team` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '客队球队id',
  `start_time` timestamp NOT NULL DEFAULT '1978-12-31 16:00:00' COMMENT '比赛开始时间',
  `end_time` timestamp NULL DEFAULT NULL COMMENT '比赛结束时间',
  `create_time` timestamp NOT NULL DEFAULT '1978-12-31 16:00:00' COMMENT '创建时间',上面是表结构
要求连胜,连续不败,连败,连续不胜,连续不得分,连续有得分,可以只判断主场的情况

解决方案 »

  1.   

    CREATE TABLE `t_game_result_full` (
      `game_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '比赛id',
      `game_type` int(3) unsigned NOT NULL DEFAULT '0' COMMENT '比赛类型',
      `home_team` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '主队球队id',
      `home_score` int(11) unsigned DEFAULT '0' COMMENT '主队得分',
      `away_score` int(11) unsigned DEFAULT '0' COMMENT '客队得分',
      `away_team` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '客队球队id',
      `start_time` timestamp NOT NULL DEFAULT '1978-12-31 16:00:00' COMMENT '比赛开始时间',
      `end_time` timestamp NULL DEFAULT NULL COMMENT '比赛结束时间',
      `create_time` timestamp NOT NULL DEFAULT '1978-12-31 16:00:00' COMMENT '创建时间',
      PRIMARY KEY (`game_id`),
      KEY `idx_game_game_type` (`game_type`) USING BTREE,
      KEY `idx_game_home_team` (`home_team`) USING BTREE,
      KEY `idx_game_away_team` (`away_team`) USING BTREE
    ) ENGINE=InnoDB AUTO_INCREMENT=54315 DEFAULT CHARSET=utf8 COMMENT='比赛结果记录表';
      

  2.   

    CREATE TABLE `t_game_result_full` (
      `game_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '比赛id',
      `game_type` int(3) unsigned NOT NULL DEFAULT '0' COMMENT '比赛类型',
      `home_team` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '主队球队id',
      `home_score` int(11) unsigned DEFAULT '0' COMMENT '主队得分',
      `away_score` int(11) unsigned DEFAULT '0' COMMENT '客队得分',
      `away_team` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '客队球队id',
      `start_time` timestamp NOT NULL DEFAULT '1978-12-31 16:00:00' COMMENT '比赛开始时间',
      `end_time` timestamp NULL DEFAULT NULL COMMENT '比赛结束时间',
      `create_time` timestamp NOT NULL DEFAULT '1978-12-31 16:00:00' COMMENT '创建时间',
      PRIMARY KEY (`game_id`),
      KEY `idx_game_game_type` (`game_type`) USING BTREE,
      KEY `idx_game_home_team` (`home_team`) USING BTREE,
      KEY `idx_game_away_team` (`away_team`) USING BTREE
    ) ENGINE=InnoDB AUTO_INCREMENT=54315 DEFAULT CHARSET=utf8 COMMENT='比赛结果记录表';   2. 你的 insert into xxx ... 语句
       3. 结果是什么样,(并给以简单的算法描述)

    这两样贴出
      

  3.   

    如果只找某只球队的连胜场次的话select max(cnt) as maxwin 
    from (
    select home_team,case when home_score > away_score then @cnt := @cnt + 1 else @cnt:=0 end as cnt
    from t_game_result_full,(select @cnt :=0) a
    where home_team = :主队id
    order by game_id) b连平连败改下条件就可以。如果想统计所有球队的……没想好……
      

  4.   

    http://blog.csdn.net/baidu_23174957/article/details/41649343