In MySQL, the IS and IS NOT operators are both used to test a value against a Boolean value.
The syntax of the IS operator can be as follows:
Val IS Boolean_val
Here Val is the value that we want to test against Boolean value.
Boolean_val is the Boolean value against which the value would be tested and it can be TRUE, FALSE or UNKNOWN.
The syntax of IS NOT operator can be as follows −
Here, Val is the value we want to test against the boolean value.
Boolean_val is the Boolean value to be tested, it can be TRUE, FALSE or UNKNOWN.
IS NOT The syntax of the operator can be as follows −
Val IS NOT Boolean_val
Here, Val is the boolean value we want to test against value.
Boolean_val is the Boolean value to be tested against, which can be TRUE, FALSE or UNKNOWN.
The following MySQL statements will demonstrate the above −
mysql> Select 1 IS TRUE, 0 IS FALSE, NULL IS UNKNOWN; +-----------+------------+-----------------+ | 1 IS TRUE | 0 IS FALSE | NULL IS UNKNOWN | +-----------+------------+-----------------+ | 1 | 1 | 1 | +-----------+------------+-----------------+ 1 row in set (0.00 sec) mysql> Select 1 IS NOT TRUE, 0 IS NOT FALSE, NULL IS NOT UNKNOWN; +---------------+----------------+---------------------+ | 1 IS NOT TRUE | 0 IS NOT FALSE | NULL IS NOT UNKNOWN | +---------------+----------------+---------------------+ | 0 | 0 | 0 | +---------------+----------------+---------------------+ 1 row in set (0.00 sec) mysql> Select 0 IS NOT TRUE, 1 IS NOT FALSE, NULL IS NOT UNKNOWN; +---------------+----------------+---------------------+ | 0 IS NOT TRUE | 1 IS NOT FALSE | NULL IS NOT UNKNOWN | +---------------+----------------+---------------------+ | 1 | 1 | 0 | +---------------+----------------+---------------------+ 1 row in set (0.00 sec)
The above is the detailed content of What are the uses of MySQL's IS and IS NOT operators?. For more information, please follow other related articles on the PHP Chinese website!