Skip to content

Instantly share code, notes, and snippets.

@austinbv
Created June 27, 2011 18:23
Show Gist options
  • Save austinbv/1049430 to your computer and use it in GitHub Desktop.
Save austinbv/1049430 to your computer and use it in GitHub Desktop.
SELECT DISTINCT `matches`.`id` FROM `players`
INNER JOIN `league_registrations` ON (`league_registrations`.`player_id` = `players`.id OR second_player_id = `players`.`id`)
INNER JOIN `matches` ON (`matches`.`home_league_registration_id` = `league_registrations`.`id` OR `matches`.`away_league_registration_id` = `league_registrations`.`id`)
WHERE `players`.`id` = 113
INTERSECT
SELECT DISTINCT `matches`.`id` FROM `players`
INNER JOIN `league_registrations` ON (`league_registrations`.`player_id` = `players`.id OR second_player_id = `players`.`id`)
INNER JOIN `matches` ON (`matches`.`home_league_registration_id` = `league_registrations`.`id` OR `matches`.`away_league_registration_id` = `league_registrations`.`id`)
WHERE `players`.`id` = 8883
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment