Skip to content

Instantly share code, notes, and snippets.

@keo
Created July 25, 2011 10:40
Show Gist options
  • Save keo/1103892 to your computer and use it in GitHub Desktop.
Save keo/1103892 to your computer and use it in GitHub Desktop.
SELECT people.*
FROM `people`
INNER JOIN
`people_sections` ON `people`.`id` = `people_sections`.`person_id` AND `people_sections`.`deleted_at` IS NULL
INNER JOIN `event_types` ON `event_types`.`section_id` = `people_sections`.`section_id` AND `event_types`.`deleted_at` IS NULL
INNER JOIN `events` ON `events`.`event_type_id` = `event_types`.`id` AND `events`.`competition_id` = 16777237 AND `events`.`deleted_at` IS NULL
WHERE
`people`.`deleted_at` IS NULL
AND (`people`.`country_id` = 16777217)
GROUP BY `people`.`id`
ORDER BY lastname, firstname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment