select* from table1 WHERE (CM_PLAN_ID,Individual_ID) IN ( Select CM_PLAN_ID, Individual_ID From CRM_VCM_CURRENT_LEAD_STATUS Where Lead_Key = :_Lead_Key )
要实现上面的in multiple columns的话
1 2 3 4 5 6 7 8 9 10 11 12
select*from table1 LEFTJOIN ( Select CM_PLAN_ID, Individual_ID From CRM_VCM_CURRENT_LEAD_STATUS Where Lead_Key = :_Lead_Key ) table2 ON table1.CM_PLAN_ID=table2.CM_PLAN_ID AND table1.Individual=table2.Individual WHERE table2.CM_PLAN_ID ISNOTNULL
有distinct的问题
1 2 3 4 5 6 7
SELECT* FROM table1 WHEREEXISTS (SELECT* FROM table2 WHERE Lead_Key =@Lead_Key AND table1.CM_PLAN_ID = table2.CM_PLAN_ID AND table1.Individual_ID = table2.Individual_ID)