IS NULL

Description

The IS NOT NULL function tests whether a value is NULL.

It returns TRUE if a NULL value is found, otherwise it returns FALSE. It can be used in a SELECT, INSERT, UPDATE, or DELETE statement.

Syntax

1. > expression IS NULL

Examples

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

4. mysql> select * from t1;
5. +-------+-------+
6. | a     | b     |
7. +-------+-------+
8. | false | true  |
9. | true  | false |
10. | true  | true  |
11. | false | false |
12. | NULL  | NULL  |
13. +-------+-------+
14. mysql> select * from t1 where a IS NULL;
15. +------+------+
16. | a    | b    |
17. +------+------+
18. | NULL | NULL |
19. +------+------+
20. 1 row in set (0.01 sec)