Skip to content

IS NULL

Grammar Description

The IS NULL operator is used to determine whether the column's value is empty. If the value is empty, it is NULL, then return true, otherwise return false. It can be used in SELECT, INSERT, UPDATE or DELETE statements.

Grammar Structure

> expression IS NULL

Example

mysql> SELECT 1 IS NULL, 0 IS NULL, NULL IS NULL;
+------------------------------------------------------------------------------------------------------------------------------
| 1 is null | 0 is null | null is null |
+------------------------------------------------------------------------------------------------------------------------------
| false | false | true |
+------------------------------------------------------------------------------------------------------------------------------
1 row in set (0.01 sec)
create table t1 (a boolean,b bool);
insert into t1 values ​​(0,1),(true,false),(true,1),(0,false),(NULL,NULL);

mysql> select * from t1;
+--------+--------+
| a | b |
+--------+--------+
| false | true |
| true | false |
| true | true |
| false | false |
| NULL | NULL |
+--------+--------+
mysql> select * from t1 where a IS NULL;
+------+------+
| a | b |
+------+------+
| NULL | NULL |
+------+------+
1 row in set (0.01 sec)