NULLs in conditional expressions

2024-06-28 05:30:31  Updated

A NULL in a conditional expression is used for logic judgment. No line is returned as the judgment result, that is UNKNOWN.

A NULL in a conditional expression indicates NULL in the condition = NULL, != NULL, NULL =, or NULL ! =.

To test for NULLs in OceanBase Database, use the comparison operator IS NULL. The returned result is TRUE or FALSE. Based on the judgment result FALSE, the judgment result NOT FALSE is TRUE. However, based on the judgment result UNKNOWN, the judgment result NOT UNKNOWN remains UNKNOWN.

The following table lists results of the conditional expression based on the value of A.

Condition Value of A Result
A = NULL 10 UNKNOWN
A != NULL 10 UNKNOWN
A = NULL NULL UNKNOWN
A != NULL NULL UNKNOWN
A = 10 NULL UNKNOWN
A != 10 NULL UNKNOWN

Note

If the condition with the judgment result UNKNOWN is used in the WHERE condition of the SELECT statement, no line is returned in the result.

Contact Us