Hosted on SourceForge
and licensed under
Creative Commons GNU GPL.
| Chris Hartjes submitted this query on: April 02, 2008 10:36am EDT | |
| TITLE | Get pitching stats from an event |
|---|---|
| SPORTS | Baseball |
| QUERY | SELECT events.event_key, baseball_pitching_stats.event_credit, persons.id AS person_id, display_names.full_name FROM stats, events , baseball_pitching_stats, persons, display_names WHERE stats.stat_repository_type = 'baseball_pitching_stats' AND stats.stat_repository_id = baseball_pitching_stats.id AND events.event_key = 'l.mlb.com-2007-e.BAL20070424' AND stats.stat_coverage_id = events.id AND stats.stat_holder_type = 'persons' AND persons.id = stats.stat_holder_id AND baseball_pitching_stats.event_credit IS NOT NULL AND display_names.entity_id = stats.stat_holder_id AND display_names.entity_type = 'persons' |
| DESCRIPTION | Given an event key, you can get the names and pitchers of record for a game by pulling in stats, baseball_pitching_stats, persons and display_names tables |
| DBs TESTED | MySQL |
| ADDITIONAL NOTES | Again, note the polymorphic joins being done with the use of stats.stat_holder_id and stats.stat_holder_type, as well as display_names.entity_id and display_names.entity_type. |