Skip to Main Content

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Seonghyun.

Asked: February 18, 2019 - 8:48 am UTC

Last updated: February 18, 2019 - 1:33 pm UTC

Version: Express 11g

Viewed 1000+ times

You Asked

Coding 1)
select comm
from emp
where comm is not null and comm != 0;


Coding 2)
select comm
from emp
where comm != 0;


The results of Coding 1 and Coding 2 are the same.

I know that the values ​​of null and 0 are different, but I do not know why.

and Chris said...

Well:

0 = the numeric value zero

null = UNKNOWN; which could mean many things, such as:
- not applicable: the attribute isn't relevant for this row
- missing: there should be a value, but someone forgot to enter it
- etc.

Your queries return the same rows because:

null != <anything>


returns UNKNOWN.

SQL statements only access rows if the where clause is TRUE. So

comm is not null


is implied in both your statements.

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

SQL

The Oracle documentation contains a complete SQL reference.