Hi Guys,
I'm new here and have come across a perplexing problem. I have a user table
CREATE TABLE Users
(
UserID VARCHAR(64),
UserName VARCHAR(50)
)
INSERT INTO Users (UserName) VALUES ('Tom')
INSERT INTO Users (UserName) VALUES ('Dick')
INSERT INTO Users (UserName) VALUES ('Harry')
Each user has roles and groups.
CREATE TABLE Roles
(
RoleID VARCHAR(64),
RoleName VARCHAR(50)
)
INSERT INTO Roles (RoleName) VALUES ('Noob')
INSERT INTO Roles (RoleName) VALUES ('Average')
INSERT INTO Roles (RoleName) VALUES ('Admin')
CREATE TABLE Groups
(
GroupID VARCHAR(64),
GroupName VARCHAR(50)
)
INSERT INTO Groups (GroupName) VALUES ('Fishing')
INSERT INTO Groups (GroupName) VALUES ('Running')
INSERT INTO Groups (GroupName) VALUES ('Base Jumping')
Linked via a couple of reference tables
CREATE TABLE UsersRoles
(
UserID VARCHAR(64),
RoleID VARCHAR(64)
)
INSERT INTO UsersRoles (UserID,RoleID) VALUES (1,1)
INSERT INTO UsersRoles (UserID,RoleID) VALUES (1,2)
INSERT INTO UsersRoles (UserID,RoleID) VALUES (1,3)
INSERT INTO UsersRoles (UserID,RoleID) VALUES (2,1)
INSERT INTO UsersRoles (UserID,RoleID) VALUES (3,1)
INSERT INTO UsersRoles (UserID,RoleID) VALUES (3,3)
CREATE TABLE UsersGroups
(
UserID VARCHAR(64),
GroupID VARCHAR(64)
)
INSERT INTO UsersGroups (UserID,GroupID) VALUES (1,1)
INSERT INTO UsersGroups (UserID,GroupID) VALUES (1,2)
INSERT INTO UsersGroups (UserID,GroupID) VALUES (2,2)
INSERT INTO UsersGroups (UserID,GroupID) VALUES (3,1)
INSERT INTO UsersGroups (UserID,GroupID) VALUES (3,3)
Now the tricky part
I am trying to get out a recordset along the lines of:
User Name Roles Groups
======= ================= =====================
Tom Noob, Average, Admin Fishing, Running
Dick Noob Running
Harry Noob, Admin Fishing, Base Jumping
Due to the constraints of Crystal Reports I can not use user defined SQL Functions. Can anybody help?
Kind regards,
Paul