First off, sorry if the title is a little off. I’ll explain my situation using an example.
I have a Groups table like this:
id name 1 admin 2 developer 3 reviewer 4 beta tester 5 contributor
I then have a Permissions table like so:
id user_id group_id 1 60 1 2 60 2 3 60 3
What I want to do is use a JOIN query to end up with a result like this:
(perm.) name part of group admin 1 developer 1 reviewer 1 beta tester 0 contributor 0
I.e. If there is an entry for a certain user ID which links to a certain group ID, that user is in that group, so a 1 is put in the column. I’m using this to print out a list of checkboxes for an admin page.
My question is simply: how can this be done in MySQL? Obviously a JOIN of some kind, but they confuse the hell out of me. Thanks for any help.
James
1 Answer