簡體   English   中英

SQL查詢WHERE過濾器獨占

[英]SQL query WHERE filter exclusive

我正在嘗試在 sql 中做一些簡單的過濾器,但沒有成功。

table1
id  table2Id table3Id name    value
1   null     1        test0   null
2   null     2        test2   null    <== i want exclude this line from my result
3   1        2        test2   MOB

當條件為table2Id = null and table3Id = 2時,我想從結果中排除,但第一個條件失敗。

我正在做:

SELECT NAME,VALUE FROM TABLE1 WHERE NOT(table2Id = null AND table3Id = 2)

並獲得:

table1
id  table2Id table3Id name    value
3   1        2        test2   MOB

我想:

id  table2Id table3Id name    value
3   1        2        test2   MOB
1   null     1        test0   null

你想要的是:

SELECT NAME,
       VALUE 
FROM TABLE1 
WHERE NOT(table2Id IS null AND table3Id = 2)

暫無
暫無

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

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