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. mysql> 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);
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 b is NOT NULL;
15. +-------+-------+
16. | a | b |
17. +-------+-------+
18. | false | true |
19. | true | false |
20. | true | true |
21. | false | false |
22. +-------+-------+
23. 4 rows in set (0.01 sec)
