Skip to content

Instantly share code, notes, and snippets.

@ptica
Last active August 29, 2015 14:10
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 ptica/fbf0ec6bb7137bdfdbb8 to your computer and use it in GitHub Desktop.
Save ptica/fbf0ec6bb7137bdfdbb8 to your computer and use it in GitHub Desktop.
giant legacy users table -> limit app queries to work only with users that have roles recognised by the app
select * from
(select
distinct "user_id"
from "roles_users"
) "my_users"
join "users"
on "my_users"."user_id" = "users"."id";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment