Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

SQL Server - clausola IN con più campi

Non nel modo in cui hai postato. Puoi restituire un solo campo o digitare IN lavorare.

Da MSDN (IN ):

test_expression [ NOT ] IN 
    ( subquery | expression [ ,...n ]
    ) 

subquery - Is a subquery that has a result set of one column. 
           This column must have the same data type as test_expression.

expression[ ,... n ] - Is a list of expressions to test for a match. 
                       All expressions must be of the same type as 
                       test_expression.

Invece di IN , potresti usare un JOIN utilizzando i due campi:

SELECT U.* 
FROM user U
  INNER JOIN userType UT
    ON U.code = UT.code
    AND U.userType = UT.userType