Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

SQL query WHERE filter exclusive

I’m trying to do some simple filter in sql but didn’t get success.

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

I want to exclude from result when the condition is table2Id = null and table3Id = 2,
but the condition fails in the first one.

i’m doing:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

and getting:

table1
id  table2Id table3Id name    value
3   1        2        test2   MOB

I want:

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

>Solution :

What you want is:

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading