|
-
May 5th, 2002, 05:49 AM
#1
Stumped on a Query
I can't figure out how to write this query I have 1 table of agencies and another of permissions for users to use those agencies. Sample data like this:
AGENCYINFO table
AGENCYID AGENCYNAME
1_________Mhc
2_________Acme
AGENCYPERMISSIONINFO Table
APERMID AGENCYID USERID
1__________1___________1
2__________2___________1
3__________1___________2
Now what I am trying to get is a list of all the agencies that a userid does NOT have permissions for.????? The closed I've come is this:
SELECT dbo.AgencyInfo.AgencyID,
dbo.AgencyInfo.AgencyName
FROM dbo.AgencyInfo INNER JOIN
dbo.AgencyPermissionInfo ON
dbo.AgencyInfo.AgencyID <> dbo.AgencyPermissionInfo.AgencyID
WHERE (dbo.AgencyPermissionInfo.UserID = 2)
And it works for userid=2 but =1 returns both of the agencies when it should return none???? Any help is appreciated.
-
May 5th, 2002, 10:04 AM
#2
Select AgencyName from AgencyInfo where AgenyInfo.AgencyId not
in
(Select AgencyInfoPermissionInfo.agencyId from AgencyPermissionInfo where User =2);
-
May 5th, 2002, 02:27 PM
#3
Jim you're the MAN, thanks a ton!!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|