[英]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. 我的问题与
Exclusion1
和Exclusion2
因为我需要我的select语句来查看sd.CollateralType
是否为Exclusion1
或Exclusion2
,其中,就目前而言,我正在对两者进行检查。
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
等于Exclusion1
或Exclusion2
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.