SQL WHERE.. IN clause multiple columns

前端 未结 13 1326
死守一世寂寞
死守一世寂寞 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:16

    select * from tab1 where (col1,col2) in (select col1,col2 from tab2)
    

    Note:
    Oracle ignores rows where one or more of the selected columns is NULL. In these cases you probably want to make use of the NVL-Funktion to map NULL to a special value (that should not be in the values);

    select * from tab1
    where (col1, NVL(col2, '---') in (select col1, NVL(col2, '---') from tab2)
    

提交回复
热议问题