在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 lows −
在這裡, 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中文網其他相關文章!