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:
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
CodePudding user response:
What you want is:
SELECT NAME,
VALUE
FROM TABLE1
WHERE NOT(table2Id IS null AND table3Id = 2)