IS NOT NULL

Description

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

If expression is NOT NULL, this function returns true. Otherwise, it returns false.

Syntax

  1. > expression IS NOT NULL

Examples

  1. > SELECT 1 IS NOT NULL, 0 IS NOT NULL, NULL IS NOT NULL;
  2. +---------------+---------------+------------------+
  3. | 1 is not null | 0 is not null | null is not null |
  4. +---------------+---------------+------------------+
  5. | true | true | false |
  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. > 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. > select * from t1 where b is NOT NULL;
  14. +-------+-------+
  15. | a | b |
  16. +-------+-------+
  17. | false | true |
  18. | true | false |
  19. | true | true |
  20. | false | false |
  21. +-------+-------+
  22. 4 rows in set (0.01 sec)