如何在where子句的case语句中使用not condition

时间:2017-05-23 06:50:06

标签: sql

我试图在SQL条件连接的情况下使用not condition但我收到错误。

select * FROM #tmpInterfaceUpdateTriger tmpTrg 

INNER JOIN Interface.InterfaceTrigger trg (NOLOCK) ON   
       tmpTrg.InterfaceTriggerID = trg.InterfaceTriggerId
INNER JOIN DataCollection.NonCustodialParentRelationship ncrp                  
     ON trg.InterfaceTriggerCode NOT IN                                      
     case when trg.IndividualId = ncrp.ChildIndividualId
             then ('AddressChange','EmploymentChange','GoodCauseChange','AbsentParentChange','CSSanctions') end

1 个答案:

答案 0 :(得分:0)

您的查询应该是这样的。

SELECT
  *
FROM #tmpInterfaceUpdateTriger tmpTrg

INNER JOIN Interface.InterfaceTrigger trg (NOLOCK)
  ON tmpTrg.InterfaceTriggerID = trg.InterfaceTriggerId
INNER JOIN DataCollection.NonCustodialParentRelationship ncrp
  ON trg.IndividualId = ncrp.ChildIndividualId
WHERE trg.InterfaceTriggerCode NOT IN ('AddressChange', 'EmploymentChange', 'GoodCauseChange', 'AbsentParentChange', 'CSSanctions')