Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    2

    Unanswered: Query Help Requested - Union?

    I need to all user IDs where the users have 3 permissions which are in a table holding about 100 different permissions

    I need to find the user IDs like I do below but somehow have all three in the WHERE clause (I guess? but this does not work)

    SELECT employees.employeeID FROM employees INNER JOIN employeePermissions ON employees.employeeID = employeePermissions.EmployeeID
    AND employeePermissions.PermissionID = 'PROJECT_VIEW_ALL'
    AND employeePermissions.PermissionID = 'PROJECT_MODIFY'
    employeePermissions.PermissionID = 'PROJECT_DELETE'


    the Permissions table has an EmployeeID column and a PermissionID column(which holds the permission name)

    PLEASE HELP.

    Thanks.

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    This assumes that employeeID and PermissionID represent a unique key in the employeePermissions table:

    select EmployeeID
    from employeePermissions
    where PermissionID in ('PROJECT_VIEW_ALL', 'PROJECT_MODIFY', 'PROJECT_DELETE')
    group by EmployeeID
    having count(*) = 3
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Mar 2004
    Posts
    2

    Thumbs up

    Thank you very much. You're the greatest!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •