Skip to content

Instantly share code, notes, and snippets.

@etianen
Created November 16, 2010 12:43
Show Gist options
  • Save etianen/701772 to your computer and use it in GitHub Desktop.
Save etianen/701772 to your computer and use it in GitHub Desktop.
SELECT DISTINCT
`people_person`.`id`,
`people_person`.`date_created`,
`people_person`.`date_modified`,
`people_person`.`access`,
`people_person`.`thumbnail`,
`people_person`.`description`,
`people_person`.`short_description`,
`people_person`.`title`,
`people_person`.`first_name`,
`people_person`.`initials`,
`people_person`.`last_name`,
`people_person`.`password_hash`,
`people_person`.`account_status`
FROM `people_person`
LEFT OUTER JOIN
`projects_personprojectrole` ON (`people_person`.`id` = `projects_personprojectrole`.`person_id`)
LEFT OUTER JOIN
`projects_project` ON (`projects_personprojectrole`.`project_id` = `projects_project`.`id`)
LEFT OUTER JOIN
`projects_personprojectrole` T4 ON (`projects_project`.`id` = T4.`project_id`)
LEFT OUTER JOIN
`organizations_personorganizationrole` ON (`people_person`.`id` = `organizations_personorganizationrole`.`person_id`)
LEFT OUTER JOIN
`organizations_organization` ON (`organizations_personorganizationrole`.`organization_id` = `organizations_organization`.`id`)
LEFT OUTER JOIN
`organizations_personorganizationrole` T8 ON (`organizations_organization`.`id` = T8.`organization_id`)
LEFT OUTER JOIN
`events_personeventrole` ON (`people_person`.`id` = `events_personeventrole`.`person_id`)
LEFT OUTER JOIN
`events_event` ON (`events_personeventrole`.`event_id` = `events_event`.`id`)
LEFT OUTER JOIN
`events_personeventrole` T12 ON (`events_event`.`id` = T12.`event_id`)
LEFT OUTER JOIN
`people_person_contacts` ON (`people_person`.`id` = `people_person_contacts`.`to_person_id`)
WHERE
(
`people_person`.`access` = 3 OR
(`people_person`.`access` = 2 AND (
T4.`person_id` = 12911 OR T8.`person_id` = 12911 OR (
`events_personeventrole`.`status` = 2 AND T12.`status` = 2 AND T12.`person_id` = 12911
)
)
) OR (
`people_person`.`access` = 1 AND `people_person_contacts`.`from_person_id` = 12911
)
) ORDER BY `people_person`.`last_name` ASC, `people_person`.`first_name` ASC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment