Ignore the use of temp tables. I only want to know which one of these ways (or if there is a better one) is better.

Personally I like using the first one

DECLARE @TB_Users TABLE (userID INT)
DECLARE @TB_Users_ToFilter TABLE (userID INT)

--Insert example data........

--Using INNER JOIN to filter
SELECT * FROM @TB_USERS U
INNER JOIN @TB_Users_ToFilter F
    ON U.userID = F.userID

--Using WHERE IN to filter
SELECT * FROM @TB_USERS U
WHERE U.userID IN (SELECT userID FROM TB_Users_ToFilter)

I have a lot of questions about optimization when i face this kind of problems and it will be so useful to me understanding this kind of things

New contributor

Ignacio Fernandez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1