RobBroekhuis
Technical User
Hi all,
Please bear with me, I'm very new with SQL, so this is pretty rudimentary. I have a database with two tables:
users (with fields name and groups)
registry (with field name and others)
A user can belong to one or more groups, A, B, C, etc. The groups field is simply a concatenation of the groups he is in, e.g. "BF".
I have one user selected. Now what I'm looking for is a query that returns all records from table registry where name refers to a user in one of the same groups as the selected user. For example:
users:
Carl BF
Rob BD
Amy ED
Max CE
registry:
Carl 1
Carl 5
Rob 3
Amy 7
Amy 9
Max 11
Max 13
If the selected user is Rob, then the query should return all of the registry records belonging to Carl, Rob, and Amy, but not those belonging to Max, because Max and Rob do not share a group.
Am I making sense?
Rob
Please bear with me, I'm very new with SQL, so this is pretty rudimentary. I have a database with two tables:
users (with fields name and groups)
registry (with field name and others)
A user can belong to one or more groups, A, B, C, etc. The groups field is simply a concatenation of the groups he is in, e.g. "BF".
I have one user selected. Now what I'm looking for is a query that returns all records from table registry where name refers to a user in one of the same groups as the selected user. For example:
users:
Carl BF
Rob BD
Amy ED
Max CE
registry:
Carl 1
Carl 5
Rob 3
Amy 7
Amy 9
Max 11
Max 13
If the selected user is Rob, then the query should return all of the registry records belonging to Carl, Rob, and Amy, but not those belonging to Max, because Max and Rob do not share a group.
Am I making sense?
Rob