1
select *
from someTable
where currencyid = @currencyid --CaseA
or (Currencyid in (8,11) or (@Currencyid = 0)) --CaseB
如何修改这样的查询,以便在@currencyid = 0
条件将被设置为只有CaseB而其他设置为CaseA时?有条件的SQL语句在where子句中
例如: 如果@currencyid = 0
然后结束查询被执行是
select *
from someTable
where currencyid = (Currencyid in (8,11) or (@Currencyid = 0))
@currencyid = 8
如果然后结束查询被执行是
select *
from someTable
where currencyid = @currencyid
嗯?你想要一个条件,说'@Currencyid = 0'被应用,但只有在你知道'@ CurrencyId'不能为零的情况下?这有什么意义? –
@Damien_The_Unbeliever:对不起造成混淆。我已经更新了这个问题,谢谢 –