在MySQL中, IS和 IS NOT操作符都用于将一个值与布尔值进行测试。
IS操作符的语法可以如下所示:
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 −
在这里, Val是我们想要与布尔值进行测试的值。
Boolean_val 是要对其进行测试的布尔值,它可以是TRUE、FALSE或UNKNOWN。
IS NOT 运算符的语法可以如下所示−
Val IS NOT Boolean_val
在这里, Val 是我们想要根据布尔值进行测试的值。
Boolean_val 是要根据其进行测试的布尔值,可以是TRUE、FALSE或UNKNOWN。
以下MySQL语句将演示上述内容−
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)
以上是MySQL的IS和IS NOT运算符有什么用途?的详细内容。更多信息请关注PHP中文网其他相关文章!