Ms sql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adnan jan
    New Member
    • Jan 2012
    • 6

    Ms sql

    how to get users having role (id 82 "AND" 88) it should not be "IN"
    -1 88 NULL NULL
    5771 82 NULL NULL
    22306 82 NULL NULL
    22306 88 NULL NULL
    81973 82 NULL NULL
    82072 82 NULL NULL
    82078 82 NULL NULL
    82078 88 NULL NULL
    82177 88 NULL NULL
    82180 82 NULL NULL
    82180 88 NULL NULL
    82186 82 NULL NULL
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Join the table to itself and then specify the role for one side and the other role for the other side.

    Comment

    • adnan jan
      New Member
      • Jan 2012
      • 6

      #3
      thank you for an advice,,,i tried but it doesn't work,,,my required role ids are 82180, 82078, 22306

      Comment

      • adnan jan
        New Member
        • Jan 2012
        • 6

        #4
        PLZ COMMENT IF I CAN IMPROVE ON IT
        SELECT Temp1.User_id
        FROM
        (SELECT ur1.user_id FROM users_roles ur1 WHERE ur1.role_id = 82) AS Temp1 INNER JOIN
        (SELECT ur2.user_id FROM users_roles ur2 WHERE ur2.role_id = 88) AS Temp2 ON
        Temp1.user_id = Temp2.user_id

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          Is that not working?

          Comment

          Working...