Home >Database >Mysql Tutorial >When does the MySQL IN() function return NULL?
The following are two cases when the MySQL IN() function returns NULL as the result-
If the left-hand expression is NULL, the IN() function will return NULL. The following example will demonstrate it -
mysql> Select NULL IN (1,2,3,4,10); +----------------------+ | NULL IN (1,2,3,4,10) | +----------------------+ | NULL | +----------------------+ 1 row in set (0.00 sec)
IN() function If no match is found, will return NULL and one of the expressions in the list is NULL. If there is a match and one of the expressions in the list is NULL, it will return 1 as output. The following example will demonstrate it -
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)
The above is the detailed content of When does the MySQL IN() function return NULL?. For more information, please follow other related articles on the PHP Chinese website!