Query Library

Chris Hartjes submitted this query on: April 17, 2008 2:32pm EDT
TITLE Get goal scorers for a soccer game
SPORTS Soccer
QUERY SELECT
          display_names.first_name,
          display_names.last_name,
          teams.team_key,
          persons.person_key,
          soccer_offensive_stats.goals_total,
          positions.abbreviation
     FROM
          stats, teams, persons, soccer_offensive_stats, display_names, events, events_sub_seasons, sub_seasons, person_event_metadata, positions
     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_offensive_stats'
          AND stats.stat_repository_id = soccer_offensive_stats.id
          AND stats.stat_holder_type = 'persons'
          AND stats.stat_holder_id = persons.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 = 'persons'
          AND display_names.entity_id = persons.id
          AND person_event_metadata.person_id = persons.id
          AND person_event_metadata.event_id = events.id
          AND person_event_metadata.team_id = teams.id
          AND person_event_metadata.position_id = positions.id
DESCRIPTION If you know the event key for a game, you can get information from the 'soccer_offensive_stats' table for both teams and players.
DBs TESTED MySQL
ADDITIONAL NOTES