Query Library

Chris Hartjes submitted this query on: April 08, 2008 4:31pm EDT
TITLE Get player key for player given first name, last name, team and date of birth
SPORTS ALL SPORTS
QUERY SELECT persons.person_key
FROM persons, display_names, publishers, person_phases, teams
WHERE display_names.first_name = 'Edgar'
AND display_names.last_name = 'Renteria'
AND teams.team_key = 'l.mlb.com-t.8'
AND persons.birth_date = '8/7/1975'
AND display_names.entity_type = 'persons'
AND display_names.entity_id = persons.id
AND person_phases.person_id = persons.id
AND person_phases.membership_id = teams.id
AND publishers.publisher_key = 'sportsnetwork.com'
AND publishers.id = persons.publisher_id
DESCRIPTION Every publisher assigns unique keys to players, so by joining the persons, display_names, publishers, person_phases,and teams tables, you can get all more detailed info about a player
DBs TESTED MySQL
ADDITIONAL NOTES You must already know the key for the team in the database, or else you need the first part of the league key itself. In this case, you'd replace the teams.team_key part of the query with

teams.team_key LIKE 'l.mlb%'