基本上,IN() 比較函數檢查一個值是否在一組值內。如果該值在一組值內,則傳回 1,否則傳回 0。其語法如下;
Expression IN (val1, val2,…,valN)
這裡,
mysql> Select 100 IN (50,100,200,400,2000); +------------------------------+ | 100 IN (50,100,200,400,2000) | +------------------------------+ | 1 | +------------------------------+ 1 row in set (0.00 sec) mysql> Select 1000 IN (50,100,200,400,2000); +-------------------------------+ | 1000 IN (50,100,200,400,2000) | +-------------------------------+ | 0 | +-------------------------------+ 1 row in set (0.00 sec) mysql> Select 'ABC' IN ('ABCD','ABCDE','ABC'); +---------------------------------+ | 'ABC' IN ('ABCD','ABCDE','ABC') | +---------------------------------+ | 1 | +---------------------------------+ 1 row in set (0.01 sec) mysql> Select 'ABC' IN ('ABCD','ABCDE','ABCDEF'); +------------------------------------+ | 'ABC' IN ('ABCD','ABCDE','ABCDEF') | +------------------------------------+ | 0 | +------------------------------------+ 1 row in set (0.00 sec)
以上是在 MySQL 中,IN() 比較函數如何運作?的詳細內容。更多資訊請關注PHP中文網其他相關文章!