Skip to content

IS [NOT] NULL

This function can be used to determine whether an expression is equal to or not equal to NULL.

Syntax

sql
expr IS [NOT] NULL

This function returns a boolean value. The result of the IS NULL function is TRUE if the expression expr is NULL. Conversely, the IS NOT NULL function returns TRUE if expr is not NULL. In other cases, the function returns FALSE.

Examples

sql
CREATE TABLE mkw_doku.my_table (col INTEGER, TXT STRING);
INSERT INTO mkw_doku.my_table VALUES(1, NULL); 
INSERT INTO mkw_doku.my_table VALUES(2, 'Second'); 
INSERT INTO mkw_doku.my_table VALUES(3, NULL); 
INSERT INTO mkw_doku.my_table VALUES(4, 'Fourth');

SELECT * FROM mkw_doku.my_table order by col;
txt
+-----+--------+
| COL | TXT    |
+-----+--------+
| 1   | NULL   |
| 2   | Second |
| 3   | NULL   |
| 4   | Fourth |
+-----+--------+
sql
SELECT * FROM mkw_doku.my_table WHERE txt IS NOT NULL order by col;
txt
+-----+--------+
| COL | TXT    |
+-----+--------+
| 2   | Second |
| 4   | Fourth |
+-----+--------+
sql
SELECT * FROM mkw_doku.my_table WHERE txt IS NULL order by col;
txt
+-----+--------+
| COL | TXT    |
+-----+--------+
| 1   | NULL   |
| 3   | NULL   |
+-----+--------+