基本上,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中文网其他相关文章!