Skip to content

IS NOT NULL

Grammar Description

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

Grammar Structure

> expression IS NOT NULL

Example

mysql> SELECT 1 IS NOT NULL, 0 IS NOT NULL, NULL IS NOT NULL;
+------------------------------------------------------------------------------------------------------------------------------
| 1 is not null | 0 is not null | null is not null |
+------------------------------------------------------------------------------------------------------------------------------
| true | true | false |
+------------------------------------------------------------------------------------------------------------------------------
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 b is NOT NULL;
+--------+--------+
| a | b |
+--------+--------+
| false | true |
| true | false |
| true | true |
| false | false |
+--------+--------+
4 rows in set (0.01 sec)