thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Data & Analytics · Advanced

Three-Valued Logic (3VL)

SQL's logic system, in which conditions evaluate to TRUE, FALSE or UNKNOWN because of NULLs.

Definition

Any comparison involving NULL yields UNKNOWN. WHERE and HAVING keep only rows that evaluate to TRUE, while CHECK constraints reject only rows that evaluate to FALSE. This asymmetry causes subtle bugs, such as NOT IN with a subquery that returns a NULL producing no rows.

Example

WHERE x NOT IN (1, NULL) returns nothing, because every comparison is UNKNOWN.

Exam tip

NOT IN against a list containing NULL returns no rows; NOT EXISTS is the NULL-safe alternative.

Related terms