简体   繁体   中英

how to use not in condition in case statement in where clause

I am trying to use not in condition with the case for conditional join in SQL but I am getting an error.

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

Your query should be like this.

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')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM