Mysql Isnull Function

MySQL: ISNULL Function

This tutorial explains how to use the MySQL ISNULL function with syntax and examples.

Description

The MySQL ISNULL function tests whether an expression is NULL.

Syntax

The syntax for the ISNULL function in MySQL is:

ISNULL( expression )

Parameters or Arguments

expression

The value to test if NULL.

Note

  • If expression is a NULL value, the ISNULL function will return 1.
  • If expression is not a NULL value, the ISNULL function will return 0.

Applies To

The ISNULL function can be used in the following versions of MySQL:

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

Example

Let's look at some MySQL ISNULL function examples and explore how to use the ISNULL function in MySQL.

For example:

mysql> SELECT ISNULL('AODBA.com');
Output: 0

mysql> SELECT ISNULL('');
Output: 0

mysql> SELECT ISNULL(NULL);
Output: 1

mysql> SELECT ISNULL(28);
Output: 0