Function Reference

ISNULL

Checks whether a value is NULL.

MySQL 8.1
ISNULL(value)

Parameters

value
Value to check

Return value

1 if the value is NULL, otherwise 0; an empty string and 0 are not NULL

Examples

NULL, zero and empty string

MySQL 8.1
SELECT ISNULL(NULL) AS null_value,
	ISNULL(0) AS zero,
	ISNULL('') AS empty_string;
null_valuezeroempty_string
100

Checking middle name for NULL

MySQL 8.1
SELECT last_name,
	middle_name,
	ISNULL(middle_name) AS no_middle_name
FROM Teacher
WHERE id BETWEEN 9 AND 12;
last_namemiddle_nameno_middle_name
OstrozhskayaNikolaevna0
Krylov<NULL>1
Evseev<NULL>1
MoiseevRomanovich0

Details

The function only checks the value: ISNULL(x) is the same as x IS NULL. To replace NULL with another value, use IFNULL or COALESCE: in SQL Server ISNULL(a, b) replaces NULL, but in MySQL two arguments give an error. PostgreSQL has no such function; the check is written as x IS NULL.

See also

Where to learn