Antipattern: Use Null as an Ordinary Value, or Vice Versa

Let's see what happens when we treat the null value as an ordinary value or vice versa.

Many software developers are caught off-guard by the behavior of NULL in SQL. Unlike most programming languages, SQL treats NULL as a unique value that is distinct from zero, false, and empty strings. This is true in standard SQL and most brands of databases. However, in Oracle and Sybase, NULL is precisely the same as a string of zero length. The NULL value follows some unique behavior, too.

Using NULL value in expressions

One case that surprises some people is when we perform arithmetic on a column or expression that is NULL. For example, many programmers would expect the result to be 10 for bugs that haven’t been given an estimate in the hours column, but instead, the query returns NULL.

Get hands-on with 1200+ tech skills courses.