Chủ Nhật, 25 tháng 5, 2014

MySQL: ISNULL Function

MySQL: ISNULL Function

Learn 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 MySQL ISNULL function is:
ISNULL( expression )

Parameters or Arguments

expression is 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 you would use the ISNULL function in MySQL.
For example:
mysql> SELECT ISNULL('techonthenet.com');
        -> 0

mysql> SELECT ISNULL('');
        -> 0

mysql> SELECT ISNULL(NULL);
        -> 1

mysql> SELECT ISNULL(28);
        -> 0

Không có nhận xét nào: