IN

语法格式:

expr IN (value,...)

说明:

如果表达式等于括号内任意一个表达式的值,返回1,否则返回0。如果所有参数都是常量,会将表达式按照类型进行分类。in匹配是通过二分法搜索实现的。这就意味着:如果in 内的参数全是常量,那么搜索就非常的快。另一方面,如果有类型转换,则会依照 Type Conversion的标准将所有参数进行类型转换。

例子:

MariaDB [(none)]> SELECT 2 IN (0,3,5,7);
+----------------+
| 2 IN (0,3,5,7) |
+----------------+
|              0 |
+----------------+
MariaDB [(none)]> SELECT 'wefwf' IN ('wee','wefwf','weg');
+----------------------------------+
| 'wefwf' IN ('wee','wefwf','weg') |
+----------------------------------+
|                                1 |
+----------------------------------+ 

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.