Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 SQL Query Help needed.

Author  Topic 

Dollarjunkie
Starting Member

1 Post

Posted - 2008-01-15 : 00:18:12
Hi,

TABLES

(Association CONTAINS COLUMNS AssociationID),
(Group CONTAINS COLUMNS GroupID, GroupName, AssociationID),
(GroupMembers CONTAINS COLUMNS GroupID, GroupMemberID, UserprofileID, DateCreated, DateRemoved),
(UserProfiles CONTAINS COLUMNS UserProfileID, UserID),
(AllUsers CONTAINS COLUMNS UserID, FirstName, LastName)

I am trying to write a query to collect information about from the tables. I need to collect all the Users who are not members of Group A in Association I.

Note that Users can belong to more than one group and have more than one profile.

I would appreciate it if you could help me figure out how to deal with this logic. Thanks in Advance



.NET Developer

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-01-15 : 00:23:58
Try . . .
SELECT u.UserID, u.FirstName, u.LastName
FROM AllUsers u
left JOIN UserProfiles p ON u.UserID = p.UserID
left JOIN GroupMembers m ON p.UserProfileID = m.UserProfileID
left JOIN Group g ON m.GroupID = g.GroupID
AND g.GroupName = 'Group A'
left JOIN Association a ON g.AssociationID = a.AssociationID
AND a.AssociationName = 'Association I'
WHERE g.GroupID IS NULL
AND a.AssociationID IS NULL



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -