ISNULL | Syntax: | ISNULL(Expression) | Return value: | INTEGER | Function type: | NULL function | |
|
|
The ISNULL() function returns 1 if the value of "Expression" is NULL.
If the value of "Expression" is not NULL, ISNULL() returns 0. |
SQL Examples for the ISNULL function |
|
SELECT isnull(null);
SELECT isnull(1);
SELECT isnull('test');
SELECT isnull(nullif(true, true));
SELECT isnull(nullif(true, false));
|
|
|
|
|
isnull(nullif(true, true)) |
int(1) |
1 |
|
|
isnull(nullif(true, false)) |
int(1) |
0 |
|
|
|
The examples were created with the MyWAY SQL manager: |
How to use the ISNULL() function in MySQL and MariaDB databases |
In MySQL and MariaDB there is the function ISNULL() that is used to check if a value is NULL or not, by returning 1 (true), if the expression is NULL or otherwise 0 (false). The function can be used in conditional filtering, for example in the WHERE clause to filter rows based on the NULL value of table columns or expressions. Furthermore, ISNULL() can be used in conditional expressions such as IF or CASE statements to process NULL values and perform different actions based on their presence or to assign default values to columns or expressions in result sets.
The behavior of ISNULL() differs from NULL comparisons with the equality operator (=). While ISNULL() specifically tests whether a value is NULL, the equality operator does not return true or false when comparing with NULL values, but NULL is always returned as the result. |
|
Further MySQL und MariaDB SQL NULL functions |
|