ISNULL()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns a boolean that indicates if the argument is NULL
.
USAGE
ISNULL(value)
Argument Name | Description |
---|---|
| The value to be tested |
DETAILS
ISNULL()
returns a boolean indicating if the expr
evaluates to NULL
.
The return value is 1
if the function argument evaluates to NULL
, otherwise it returns 0
.
EXAMPLES
With Literal Values
In the following examples, ISNULL()
is called with literal values:
SELECT ISNULL(0+1);
+-------------+
| ISNULL(0+1) |
+-------------+
| 0 |
+-------------+
SELECT ISNULL(1/0);
+-------------+
| ISNULL(1/0) |
+-------------+
| 1 |
+-------------+
Example Schema and Data
The remaining examples are based on the example table contacts
:
CREATE TABLE contacts (
first_name VARCHAR(25),
last_name VARCHAR(25),
email VARCHAR(25),
new_contact boolean
);
INSERT INTO contacts VALUES
("John","Smith","john.smith@example.com",false),
(NULL,"Smith","jane.smith@example.com",false),
("Sally","Smith",NULL,NULL),
(NULL,NULL,NULL,NULL);
Per-row Evaluation
SELECT ISNULL(first_name) AS first_name,
ISNULL(last_name) AS last_name,
ISNULL(email) AS email,
ISNULL(new_contact) AS new_contact
FROM contacts;
+------------+-----------+-------+-------------+
| first_name | last_name | email | new_contact |
+------------+-----------+-------+-------------+
| 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 |
+------------+-----------+-------+-------------+