Sorry for the not-so-great title.
I'm triyng to merge together sets of results to provide a quick view of some data.
If I have this query:
SELECT
tblPriv.ID, tblGroups.Name AS 'Group', tblPriv.User, tblPriv.Role
FROM
tblPriv
INNER JOIN
tblGroups on tblPriv.ID = tblGroups.ID
which returns these results:
ID GROUP USER ROLE
---------------------------------
1 Taxes DAVE Admin
1 Taxes JOHN Admin
1 Taxes BOB PowerUser
2 Catering RON Admin
2 Catering JACK PowerUser
2 Catering JIM PowerUser
(where ID
is relational to say, a group, stored in another table)
What I ideally want to do is get 1 record for a group:
ID GROUP ADMINS POWERUSERS
---------------------------------------------
1 Taxes DAVE; JOHN; BOB
2 Catering RON; JACK; JIM;
I know the roles beforehand - they always stay the same, and new roles are not added, ever.
How would I go about doing this? (I will also include data from other relational tables)