SQL WHERE.. IN clause multiple columns

前端 未结 13 1328
死守一世寂寞
死守一世寂寞 2020-11-29 15:56

I need to implement the following query in SQL Server:

select *
from table1
WHERE  (CM_PLAN_ID,Individual_ID)
IN
(
 Select CM_PLAN_ID, Individual_ID
 From CR         


        
13条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-29 16:11

    Simple and wrong way would be combine two columns using + or concatenate and make one columns.

    Select *
    from XX
    where col1+col2 in (Select col1+col2 from YY)
    

    This would be offcourse pretty slow. Can not be used in programming but if in case you are just querying for verifying something may be used.

提交回复
热议问题