Results 1 to 3 of 3

Thread: Stumped on a Query

  1. #1

    Thread Starter
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339

    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.

  2. #2
    jim mcnamara
    Guest
    Select AgencyName from AgencyInfo where AgenyInfo.AgencyId not
    in
    (Select AgencyInfoPermissionInfo.agencyId from AgencyPermissionInfo where User =2);

  3. #3

    Thread Starter
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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
  •  



Click Here to Expand Forum to Full Width