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