Skip to content

Instantly share code, notes, and snippets.

@voltechs
Created July 8, 2012 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voltechs/3073456 to your computer and use it in GitHub Desktop.
Save voltechs/3073456 to your computer and use it in GitHub Desktop.
Memberships ordered by the rank of membership's role.
SELECT `memberships`.* from `memberships`
INNER JOIN `groups` ON `groups`.id = `memberships`.group_id
INNER JOIN `roles` ON `memberships`.role_id = `roles`.id
INNER JOIN `roles` `role_cat` ON `role_cat`.id = `roles`.type_id
WHERE `groups`.id = "HHC" AND `memberships`.expiration > CURDATE()
ORDER BY `role_cat`.rank DESC, `roles`.rank DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment