J
Joe Butler
using sql,
with this table:
id_group id_user
g1 u1
g1 u2
g1 u3
g2 u1
g2 u2
g2 u4
g3 u2
g3 u4
g3 u5
how can I get a list of id_group's that contain a sub-set of specified
users?
E.g.
specifying
(id_user = u2) and (id_user = u4)
would produce result set:
g2
g3
specifying
(id_user = u1) and (id_user = u2) and (id_user = u3)
would produce result set:
g1
I'm think I should be using one of these methods to do it...
SQL: IN, GROUP BY, HAVING
or
SQL: TRANSFORM, PIVOT
Being new to SQL and only done a bit of straightforward database stuff
before, this is not entirely obvious to me yet.
tia
with this table:
id_group id_user
g1 u1
g1 u2
g1 u3
g2 u1
g2 u2
g2 u4
g3 u2
g3 u4
g3 u5
how can I get a list of id_group's that contain a sub-set of specified
users?
E.g.
specifying
(id_user = u2) and (id_user = u4)
would produce result set:
g2
g3
specifying
(id_user = u1) and (id_user = u2) and (id_user = u3)
would produce result set:
g1
I'm think I should be using one of these methods to do it...
SQL: IN, GROUP BY, HAVING
or
SQL: TRANSFORM, PIVOT
Being new to SQL and only done a bit of straightforward database stuff
before, this is not entirely obvious to me yet.
tia