簡體   English   中英

Oracle SQL where 子句與 case when 不同

[英]Oracle SQL different where clauses with case when

愚蠢的問題,因為我想開始一個 select 語句,其中有兩個 where 子句選項,並停留在我可以過濾它的部分。 問題是,我希望選項說“如果 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

我敢打賭這非常容易,但不知何故我看不到它。

使用ANDOR和括號:

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))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM