Skip to content

Instantly share code, notes, and snippets.

@moff
Created March 2, 2017 13:27
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 moff/94edb478481db0ba8beacad6067e54b3 to your computer and use it in GitHub Desktop.
Save moff/94edb478481db0ba8beacad6067e54b3 to your computer and use it in GitHub Desktop.
SELECT u.login, GROUP_CONCAT(DISTINCT p.nm ORDER BY p.nm ASC) AS projects FROM users AS u
LEFT JOIN user_project_rel AS upr ON u.id = upr.user_id
LEFT JOIN projects AS p ON p.id = upr.project_id
GROUP BY u.login;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment