SQL Server - IN clause with multiple fields

后端 未结 8 713
野性不改
野性不改 2020-12-20 11:42

Is it possible to include in a IN clause multiple fields? Something like the following:

select * from user
where code, userType in ( select code         


        
8条回答
  •  眼角桃花
    2020-12-20 12:12

    I had to do something very similar but EXISTS didn't work in my situation. Here is what worked for me:

    UPDATE tempFinalTbl
    SET BillStatus = 'Non-Compliant'
    WHERE ENTCustomerNo IN ( SELECT DISTINCT CustNmbr
                 FROM tempDetailTbl dtl
                WHERE dtl.[Billing Status] = 'NEEDS FURTHER REVIEW'
                  AND dtl.CustNmbr = ENTCustomerNo 
                  AND dtl.[Service] = [Service]) 
      AND [Service] IN  ( SELECT DISTINCT [Service] 
                 FROM tempDetailTbl dtl
                WHERE dtl.[Billing Status] = 'NEEDS FURTHER REVIEW'
                  AND dtl.CustNmbr = ENTCustomerNo 
                  AND dtl.[Service] = [Service]) 
    

    EDIT: Now that I look, this is very close to @v1v3kn's answer

提交回复
热议问题