MySQL IS NULL

The MySQL IS NULL is used to test whether the user given expression or column value is NULL or not. You can use this IS function inside a Where clause to find the records with NULL values.

The basic syntax behind this MySQL IS NULL is as follows:

SELECT Column_Names  
FROM Table_Name
WHERE Column_Value IS NULL

Simple MySQL IS NULL Example

In this example, we show you simple examples of this one. Here, 1 is Not, and 0 or NULL are Null Values. In the last statement, 1/0 is a NULL.

SELECT 1 IS NULL;

SELECT 0 IS NULL, NULL IS NULL;

SELECT 1/0 IS NULL, 0/1 IS NULL;
Finding empty 1

For this demonstration, We are going to use the Employee Details table. The following screenshot shows you the data inside this table.

Customer Table records 2

In this example, we use this one to return all the Employees details whose Middle Name is a NULL value.

SELECT 
       CustomerKey,
       FirstName, 
       MiddleName,
       LastName,
       YearlyIncome,
       Phone,
       Office,
       Mobile
 FROM EmployeeDetails
 WHERE MiddleName IS NULL;
IS NULL Example 3

The following Query returns all the employee records whose Phone number is NULL.

SELECT 
       CustomerKey,
       FirstName, 
       MiddleName,
       LastName,
       YearlyIncome,
       Phone,
       Office,
       Mobile
 FROM EmployeeDetails
 WHERE Phone IS NULL;
Empty Phone Numbers 4

Until now, we are using this IS NULL on a single column. In this example, we use this operator to return all the employee details, whose Personal Phone number or Office numbers are NULL values

SELECT 
       CustomerKey,
       FirstName, 
       MiddleName,
       LastName,
       YearlyIncome,
       Phone,
       Office,
       Mobile
 FROM EmployeeDetails
 WHERE Phone IS NULL OR Office IS NULL;
MySQL IS NULL Operator 5

Here, we are finding the employees whose Middle, and their Phone number is Null.

SELECT 
       CustomerKey,
       FirstName, 
       MiddleName,
       LastName,
       YearlyIncome,
       Phone,
       Office,
       Mobile
 FROM EmployeeDetails
 WHERE MiddleName IS NULL AND Phone IS NULL;
Example 6