first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

SQL: AND and OR Operate on True, False and Null

These equations are derived from the so-called "Truth Tables":

True AND True = True
True AND False = False
True AND Null = Null

False AND True = False
False AND False = False
False AND Null = False

Null AND True = Null
Null AND False = False
Null AND Null = Null

True OR True = True
True OR False = True
True OR Null = True

False OR True = True
False OR False = False
False OR Null = Null

Null OR True = True
Null OR False = Null
Null OR Null = Null

Note that: !(A OR B) = !A AND !B

Some database administrators do not like the use of Nulls in tables. Heavy dependence on Nulls often implies violation(s) of normalization rules. You can see how these truth tables are made very complicated by the prescence of Nulls. In the place of Null the term Unknown is often used.

mod date: 2000-12-24T22:47:33.000Z