 <pre><code>;WITH set1 AS (SELECT * FROM Privileges WHERE Privilege IN (1, 3)) SELECT up.UserId FROM UserPrivileges up INNER JOIN set1 ON set1.Privilege = set1.Privilege GROUP BY up.UserId HAVING COUNT(up.Privilege) = (SELECT COUNT(*) FROM set1); </code></pre>