I’m quite confused as to how I’d structure a query I need:
select distinct NodeID from GroupsTable
where GroupID in
(
select GroupID from UserGroupsTable
where UserID = @UserID
)
I need to select NodeID from GroupsTable where the User belongs to multiple groups, UNLESS any group that the user belongs to does not have that NodeID.
The above code only selects a NodeID from GroupsTable where it apears in any one of the users groups.
So:
Group|Node
1|A
1|B
2|A
I need only B to be selected for example.
Any Ideas?
(assuming this is SQL Server and version >= 2005 for using the count(*) over)
@answer HAVING condition changed following comments