Created
July 17, 2020 08:56
-
-
Save slav123/00b00046a02eca56996284b5c0f2d964 to your computer and use it in GitHub Desktop.
Single query to pull users with group names.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT id, email, (SELECT GROUP_CONCAT(ag.name) FROM auth_groups_users gu LEFT JOIN auth_groups ag ON ag.id=gu.group_id WHERE gu.user_id=u.id ) FROM users u |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment