Many-to-many query (chained)

2007-09-29 Thread Rapthor
Hi SQLers, I am searching for an SQL command to combine several many-to-many queries. At the end I only want to get results suitable for all restrictions. Better show you my tables: USER id name 1 frank ROLE id name 1 admin 2 general GROUP id name 1 groupA 2 groupB USER_ROLE us

Re: Many-to-many query (chained)

2007-09-29 Thread Rapthor
=ug.user_id AND (ug.group_id=1 OR ug.group_id=2) HAVING COUNT( DISTINCT ur.role_id ) = 2 AND COUNT( DISTINCT ug.group_id ) = 2 GROUP BY name; Thanks! You really saved my day! pzbrawl wrote: > > Rapthor, > > Try ... > > SELECT u.name > FROM user u > JOIN user_role ur ON u.i