如何解决Oracle SQL 与 case when 不同的 where 子句
愚蠢的问题,因为我想用 where 子句的两个选项开始一个 select 语句,并卡在我可以过滤它的部分。问题是,我想要选项说“如果 RS_BEM 是 A1 或 A2,则搜索不在列表中的 ID,如果还有其他内容,则搜索列表中的 ID”。
and Case when :RS_BEM like 'A1' or :RS_BEM like 'A2' then ate_msg_nr not in (select * from StoerIDs) else ate_msg_nr in (select * from StoerIDs) end
我敢打赌这非常简单,但不知何故我没有看到。
解决方法
使用 AND
、OR
和括号:
where (:RS_BEM in ('A1','A2') and ate_msg_nr not in (select * from StoerIDs))
or (:RS_BEM not in ('A1','A2') and ate_msg_nr in (select * from StoerIDs))
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。