Query Library

Chris Hartjes submitted this query on: April 02, 2008 9:37am EDT
TITLE Get all hits by teams in a specific game
SPORTS Baseball
QUERY SELECT events.event_key, teams.team_key, baseball_offensive_stats.hits
FROM stats,
EVENTS , baseball_offensive_stats, teams
WHERE stats.stat_repository_type = 'baseball_offensive_stats'
AND stats.stat_repository_id = baseball_offensive_stats.id
AND events.event_key = 'l.mlb.com-2007-e.WAS200705200'
AND stats.stat_coverage_id = events.id
AND stats.stat_coverage_type = 'events'
AND stats.stat_holder_type = 'teams'
AND teams.id = stats.stat_holder_id
DESCRIPTION given the event key for a baseball game, you can go look in the baseball_offensive_stats table to find out how many hits the teams involved in that game had.
DBs TESTED MySQL
ADDITIONAL NOTES