Predicates
A predicate is a simple expression asserting some fact, let’s call it P
.If P
resolves as TRUE, it succeeds.If it resolves to FALSE or NULL (UNKNOWN), it fails.A trap lies here, though: suppose the predicate, P
, returns FALSE.In this case NOT(P)
will return TRUE.On the other hand, if P
returns NULL (unknown), then NOT(P)
returns NULL as well.
In SQL, predicates can appear in CHECK
constraints, WHERE
and HAVING
clauses, CASE
expressions, the IIF()
function and in the ON
condition of JOIN
clauses, and anywhere a normal expression can occur.