SQL NULL Functions
Following SQL Null Functions are discussed in this section. There are FOUR NULL functions used in SQL Database;And the function types mentioned below:
Types of SQL Null Functions
- SQL ISNULL()
- SQL IFNULL()
- SQL COALESCE()
- SQL NVL()
ISNULL Function in SQL
The ISNULL function is used to replace NULL values in SQL Server:
SQL ISNULL() Syntax
SELECT column_name(s),
ISNULL (column_name, value_to_replace)
FROM table_name;
MySQL ISNULL() Syntax
SELECT column_name(s)
FROM table_name
WHERE ISNULL (column_name);
IFNULL Function in SQL
The IFNULL function is used only in MySQL Server. In SQL Server & Oracle, we can't use IFNULL function.
SQL IFNULL() Syntax
SELECT column_name(s),
IFNULL (column_name, value_to_replace)
FROM table_name;
COALESCE Function in SQL
The COALESCE function returns first NON-NULL expression among its arguments in SQL server.
SQL COALESCE() Syntax
SELECT column_name(s),
COALESCE (column_name1, column_name2, column_name3, ...)
FROM table_name;
NVL Function in SQL
The NVL function is available only in Oracle database, it is not available in MySQL or SQL server.
- The NVL function is used to replace NULL value with another value.
- The NVL function is similar to the IFNULL function in MySQL server.