Skip to content

IS

Grammar Description

The IS operator is used to test whether the value is a Boolean value. If it is a Boolean value, the result is true. where boolean_value can be TRUE, FALSE or UNKNOWN.

Grammar Structure

> IS boolean_value

Example

mysql> SELECT 1 IS TRUE, 0 IS FALSE, NULL IS UNKNOWN;
+------------------------------------------------------------------------------------------------------------------------------
| 1 is true | 0 is false | null is unknown |
+------------------------------------------------------------------------------------------------------------------------------
| true | true | true |
+------------------------------------------------------------------------------------------------------------------------------
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 a<=b and a is not NULL;
+--------+--------+
| a | b |
+--------+--------+
| false | true |
| true | true |
| false | false |
+--------+--------+
3 rows in set (0.01 sec)