Great! With a little adaption it works! Yes and of course I have to use
another name for groups :) It was just an example. I have slightly different
table settings.
SELECT u.name
FROM user u
JOIN user_role ur ON u.id=ur.user_id AND (ur.role_id=1 OR ur.role_id=2)
JOIN user_group ug ON u.id=ug.user
Rapthor,
Try ...
SELECT u.name
FROM user u
JOIN user_role ur ON u.id=ur.user_id AND (u.id=1 OR u.id=2)
JOIN user_group ug ON u.id=ug.user_id AND (u.id=1 OR u.id=2)
HAVING COUNT( DISTINCT ur.role_id ) = 2
AND COUNT( DISTINCT ug.group_id ) = 2;
BTW you can't name a table 'group'; it's a reserve
- Original Message -
From: "Emily Lena Jones" <[EMAIL PROTECTED]>
To: "Rhino" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, October 28, 2004 7:46 PM
Subject: Re: many-to-many query
>
> Quoting Rhino <[EMAIL PROTECTED]>:
>
Quoting Rhino <[EMAIL PROTECTED]>:
> I wasn't sure if you understood the concept of association tables so forgive
> me if I told you things you already knew; I didn't mean to be patronizing.
No problem--you weren't patronizing at all, and I did tell you I was new at
this!
> With respect to you
- Original Message -
From: "Emily Lena Jones" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, October 28, 2004 4:05 PM
Subject: many-to-many query
> Hi, I'm totally new at this so have no idea whether I'm asking for
something
> easy or quite difficult.
>
> I am working in My