Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between "column is null" and "column = null" in where clause in db2?

Tags:

sql

db2

I am getting different results when I run the query with above clause but not able to understand why. can any one explain what is the difference between the two clauses.

like image 476
GuruKulki Avatar asked Dec 12 '22 10:12

GuruKulki


2 Answers

The result of column = null is unknown (null), since it can't be known what null really is. If you want to test for null and get a boolean value back you need to use is null. So, `column` is null is the correct syntax to use.

like image 107
Paul Avatar answered Dec 28 '22 23:12

Paul


A comparison to null always evaluates to false, so column = null evaluates to false as well as column != null, independently of the value of column. If you want to actually check whether a value is null, you have to use column is null.

like image 34
phlogratos Avatar answered Dec 29 '22 00:12

phlogratos