w3resource

MySQL IS operator

IS operator

MySQL IS operator tests a value against a Boolean value. A boolean value can be TRUE, FALSE, or UNKNOWN.

Syntax:

IS boolean_value

MySQL Version: 8.0

Example: MySQL IS operator

In the following MySQL statement, it is checked whether 5 is TRUE, 0 is TRUE and NULL is UNKNOWN using IS operator. For the first and third case it returns 1, for the second case, it returns 0.

Code:

SELECT 5 IS TRUE, 0 IS TRUE, NULL IS UNKNOWN;

Output:

mysql> SELECT 5 IS TRUE, 0 IS TRUE, NULL IS UNKNOWN;
+-----------+-----------+-----------------+
| 5 IS TRUE | 0 IS TRUE | NULL IS UNKNOWN |
+-----------+-----------+-----------------+
|         1 |         0 |               1 | 
+-----------+-----------+-----------------+
1 row in set (0.02 sec)

Slideshow of MySQL Comparison Function and Operators

Previous: IS NULL
Next: ISNULL()



Follow us on Facebook and Twitter for latest update.