Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle sql null value is not selected

Tags:

sql

oracle

In NAME table FIRST column is having null but no rows are selected. Please help me to understand.

SELECT * FROM NAME WHERE FIRST != '1'
like image 869
sunleo Avatar asked Feb 21 '13 03:02

sunleo


1 Answers

NULL is dumb. Period.

NULL is evil.

If X is NULL and Y is NULL, then X does in fact equal Y because they are both NULL.

It's also a PITA that I can't say

IF X IN ('a','B','C', null)

Because this condition happens. But now I have to say

IF ( X IN ('a','B','C') or X is NULL ) 

which is a waste of time and a risk of error if I forget the parentheses.

What irks me further is that NULL shouldn't happen in the first place. Fields (er... ok kids, I'll call them Columns) should always be initialized. Period. Stop the nulls. Don't allow them. Default values should always be zeroes or blanks so that those folks that are too lazy to initialize columns in their software will have them initialized for them automatically.

There are many instances where a failure to define default values of zeroes and blanks makes life more difficult than it has to be.

like image 135
AS400Jockey Avatar answered Oct 11 '22 14:10

AS400Jockey