IS NULL

IS NULL is used to test if an expression is null.

Syntax

expr IS [ NOT ] NULL

Arguments

Parameter

Description

expr

A general value expression or a literal to test.

Returns

Returns TRUE when expr is NULL or FALSE otherwise.

Examples

For these examples, consider the following table and contents:

CREATE TABLE t (id INT NOT NULL, name TEXT(30), weight INT);

INSERT INTO t VALUES (1, 'Kangaroo', 120), (2, 'Koala', 20), (3, 'Wombat', 60)
                    ,(4, 'Kappa', NULL),(5, 'Echidna', 8),(6, 'Chupacabra', NULL)
                    ,(7, 'Kraken', NULL);

IS NULL

m=> SELECT * FROM t WHERE weight IS NULL;
id | name       | weight
---+------------+-------
 4 | Kappa      |
 6 | Chupacabra |
 7 | Kraken     |

Using IS NOT NULL to filter unwanted results

m=> SELECT AVG(weight) FROM t WHERE weight IS NOT NULL;
avg
---
52