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¶
Text
> IS boolean_value
Example¶
Text
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)
Text
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)
Last updated on