我正在使用存储过程从现有表中提取数据,该存储过程具有用户通过复选框在前端选择的一些是或否选项。我想限制If
为他们做出的每个选择写一堆不同的陈述。
我的 where 子句的这一部分有效。数据是Y
或N
用于此列。
Where... and IsSigned = Case When @IncludeSigned = 'Y' then IsSigned else 'N' end
我想添加到 where usingis not null
以及not like
是否可以在方括号之间添加。到目前为止我有
and SignatureType = case when @IncludeElectronic = 'Y' then Type else [NOT like electronic] end
还
and ReviewDate = Case When @HasReviewDate = 'Y' then [ReviewDate is not null] else null end
这可能会帮助您使用 AND/OR 而不是 case
where (ReviewDate is not null or @HasReviewDate = 'Y' ) And (....)
即当@HasReviewDate = 'Y' 查询将返回ReviewDate 不为空的记录,当@HasReviewDate != 'Y' 时查询将返回ReviewDate 为空的记录
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句