August 26th, 2008

IS NULL (Unknown Value)

Posted by admin in D. WHERE Clause

> NULLs represent missing or unknown values.
> A NULL does not match any value, not even other NULLs.
> “= NULL” can not be used because unknown values do not satisfy specific conditions.The RDBMS engine may try to convert NULL to a string and look for the letters N-U-L-L.
SQL uses “IS NULL” to determine a null condition.

SELECT column1, column2, ...
  FROM table1, table2, ...
 WHERE testcolumn IS [NOT] NULL, ...;

> IS NULL works for columns of any data type.
> You can find a non-NULL condition with IS NOT NULL.
> You can combine IS NULL with other conditions using AND and OR.
> A NULL is not the same thing as an empty string (”).
> Oracle is the exception because it treats an empty sting (”) as a null.
> You can forbid nulls in a table with NOT NULL in the TABLE definition. See Data Definition Language (DDL).

August 25th, 2008

AND, OR, and NOT, Part 3 of 3

Posted by admin in D. WHERE Clause

Sometimes you can rewrite a condition, so that its meaning is easier to grasp.These two statements are equivalent:

Which one was easier for you to understand?

We are used to saying, “Less than 10,000 AND more than 100,000.” But if we write:

This will never return data, because if the price is less than 10,000, then the price can not be greater than 100,000. Rewrite the statement:

August 22nd, 2008

AND, OR, and NOT, Part 2 of 3

Posted by admin in D. WHERE Clause

> NOT does not connect two conditions like AND and OR.
Instead it reverses a single condition.

> NOT is placed before the column name or expression
and not before the operator.

> NOT acts on only one condition.
To reverse two or more conditions,
repeat the NOT for each condition.

> The following two statements are equivalent.
Choose whichever style works best for you.

« Previous PageNext Page »