以下是MySQLIN()
函数返回NULL作为结果的两种情况-
如果左侧的表达式为NULL,则IN()函数将返回NULL。以下示例将演示它-
mysql> Select NULL IN (1,2,3,4,10); +----------------------+ | NULL IN (1,2,3,4,10) | +----------------------+ | NULL | +----------------------+ 1 row in set (0.00 sec)
如果找不到任何匹配项且列表中的表达式之一为NULL,则IN()函数将返回NULL。如果存在匹配项,并且列表中的表达式之一为NULL,则它将返回1作为输出。以下示例将演示它-
mysql> Select 10 IN (NULL,11,12); +--------------------+ | 10 IN (NULL,11,12) | +--------------------+ | NULL | +--------------------+ 1 row in set (0.00 sec) mysql> Select 10 IN (NULL,11,12,10); +-----------------------+ | 10 IN (NULL,11,12,10) | +-----------------------+ | 1 | +-----------------------+ 1 row in set (0.00 sec)