0

I have the following table.

User Permission John 1 Mary 1 Anne 1 Joe 2 Marie 2 Nick 3

I want to select and group users with the same permission number. Is this actually possible? I have millions of different permission values.

Expected output:

(John, Mary, Anne), (Joe, Marie), (Nick)

1

It's probably best to do this in the application, after all it's just presentation. Something like:

SELECT user, permission
FROM T
ORDER BY permission

then keep track of when permission changes.

However (untested), there seems to be a GROUP_CONCAT function that can do what you want:

SELECT GROUP_CONCAT(user), permission
FROM T
GROUP BY permission
ORDER BY permission

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.