简体   繁体   English

如果单元格值等于值A或值B则为SQL

[英]SQL if cell value equals value A or value B

I'm writing a proc which has the following select statement in it 我正在写一个过程,其中包含以下选择语句

SELECT expectedValue
FROM dbo.ExclusionValues ev
JOIN dbo.StagingData sd ON ev.ExpectedVale = sd.ProductMainType
                            AND ev.Exclusion1 = sd.CollateralType
                            AND ev Exclusion2 = sd.CollateralType

My issue is with Exclusion1 & Exclusion2 as I need my select statement to see if sd.CollateralType is either Exclusion1 or Exclusion2 where as right now, I'm checking on both. 我的问题与Exclusion1Exclusion2因为我需要我的select语句来查看sd.CollateralType是否为Exclusion1Exclusion2 ,其中,就目前而言,我正在对两者进行检查。

What is the correct syntax for doing so? 这样做的正确语法是什么?

The above snippet is from a larger proc I'm adding to and I can't provide more background on it. 上面的代码片段来自我要添加的更大的proc,因此我无法提供更多背景信息。 My issue is having a way to see if sd.CollateralType equals either Exclusion1 or Exclusion2 我的问题是有办法查看sd.CollateralType等于Exclusion1Exclusion2

Just use IN clause 只需使用IN子句

SELECT expectedValue
FROM dbo.ExclusionValues ev
JOIN dbo.StagingData sd ON ev.ExpectedVale = sd.ProductMainType
                            AND sd.CollateralType in (ev.Exclusion1, ev.Exclusion2) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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