Isnull in SQL
ISNULL Function in SQL
ISNULL is a function used to replace NULL values with a specified replacement value.
Purpose
When a column or expression returns
NULL,ISNULLlets you substitute it with a default value.Helps avoid
NULLresults in queries.
Syntax (SQL Server):
ISNULL(expression, replacement_value)expression: The value to check forNULL.replacement_value: The value to return ifexpressionisNULL.
Example:
SELECT ISNULL(phone, 'No Phone') AS phone_numberFROM employees;If
phoneisNULL, it will display'No Phone'.
Notes:
In MySQL, the equivalent is
IFNULL().In Oracle, use
NVL().ISNULLis mainly used in SQL Server and Sybase.
If you want examples in other databases or how to use it in queries, just ask!