Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Python Programs
    • Java Programs
    • SQL FAQ’s

MySQL IS NULL

by suresh

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 NULL 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 1

In this example, we show you the simple examples of the IS NULL operator. Here, 1 is Not a Null value, 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;

OUTPUT

MySQL IS NULL Operator 1

MySQL IS NULL Example 2

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

MySQL IS NULL Operator 2

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

SELECT 
    CustomerKey,
    FirstName, 
    MiddleName,
    LastName,
    YearlyIncome,
    Phone,
    Office,
    Mobile
FROM `MySQL Tutorial`.EmployeeDetails
WHERE MiddleName IS NULL;

OUTPUT

MySQL IS NULL Operator 3

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

SELECT 
    CustomerKey,
    FirstName, 
    MiddleName,
    LastName,
    YearlyIncome,
    Phone,
    Office,
    Mobile
FROM `MySQL Tutorial`.EmployeeDetails
WHERE Phone IS NULL;

OUTPUT

MySQL IS NULL Operator 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 `MySQL Tutorial`.EmployeeDetails
WHERE Phone IS NULL OR Office IS NULL;

OUTPUT

MySQL IS NULL Operator 5

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

SELECT 
    CustomerKey,
    FirstName, 
    MiddleName,
    LastName,
    YearlyIncome,
    Phone,
    Office,
    Mobile
FROM `MySQL Tutorial`.EmployeeDetails
WHERE MiddleName IS NULL AND Phone IS NULL;

OUTPUT

MySQL IS NULL Operator 6

Placed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy