Search all users that have the same badges as one particular user

0

Please login or register to vote for this query.

(click on this box to dismiss)

Chinese Language

Q&A for students, teachers, and linguists wanting to discuss the finer points of the Chinese language

-- @PostId -> need to know id of post
DECLARE @UserId int = ##UserId##

SELECT DISTINCT u.id, u.DisplayName
FROM Users u
INNER JOIN Badges b ON u.Id = b.UserId
WHERE NOT EXISTS (
  SELECT 1
  FROM Users u2
  WHERE u2.Id = @UserId AND u2.Id NOT IN (
        SELECT b2.Id
        FROM Badges b2
        WHERE b2.UserId = u.Id
  )
)

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results