Query Library

Chris Hartjes submitted this query on: April 18, 2008 9:56am EDT
TITLE Get fouls committed by team from soccer game
SPORTS Soccer
QUERY SELECT
          display_names.full_name,
          soccer_foul_stats.fouls_commited
     FROM
          stats, teams, soccer_foul_stats, display_names, events, events_sub_seasons, sub_seasons
     WHERE
          sub_seasons.sub_season_key = '2007_season_regular'
          AND events_sub_seasons.event_id = events.id
          AND events_sub_seasons.sub_season_id = sub_seasons.id
          AND stats.stat_repository_type = 'soccer_foul_stats'
          AND stats.stat_repository_id = soccer_foul_stats.id
          AND stats.stat_holder_type = 'teams'
          AND stats.stat_holder_id = teams.id
          AND stats.stat_coverage_type = 'events'
          AND stats.stat_coverage_id = events.id
          AND events.event_key = 'l.premierleague.com-2007-e.1159722'
          AND stats.context = 'event'
          AND display_names.entity_type = 'teams'
          AND display_names.entity_id = teams.id
DESCRIPTION Given the key for the event, you can pull out team-related foul information
DBs TESTED MySQL
ADDITIONAL NOTES