
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
When MySQL IN() function returns NULL?
Following are the two cases when MySQL IN() function returns NULL as result −
Case-1 − When expression on left side is NULL
IN() function will return NULL if the expression on the left side is NULL. 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)
Case-2 − When one of expression in the list is NULL and no match is found
IN() function will return NULL if it does not find any match and one of the expressions in the list is NULL. If there would be a match and one of the expressions in the list is NULL, it will return 1 as output. 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)
- Related Articles
- When MySQL MAKE_SET() function returns NULL?
- When MySQL FIND_IN_SET() function returns NULL as output?
- When MySQL LOCATE() function returns NULL as the output?
- When a MySQL arithmetic expression returns NULL?
- What MySQL returns if the argument of QUOTE() function is NULL?
- What MySQL returns if the search string, provided in FIELD() function, is NULL?
- What MySQL ASCII() function returns if I will provide NULL to it?
- What MySQL EXPORT_SET() function returns if any of the argument is NULL?
- What MySQL returns if the first argument of INTERVAL() function is NULL?
- What MySQL COALESCE() function returns if all the arguments provided to it are NULL?
- What MySQL returns when we use DISTINCT clause with the column having multiple NULL values?
- What MySQL returns if the list of strings, provided as argument in FIELD() function, are NULL?
- What MySQL COUNT() function returns if there are some NULL values stored in a column also?
- What MySQL MAKE_SET() function returns if there are all NULL at the place of strings?
- When MySQL SUBSTRING_INDEX() function returns the same string, provided in the argument, as output?

Advertisements