SQL Server ISNULL equivalent in MySQL

One of the often used functions in SQL Server is ISNULL, which aids in replacing the null values of a column with an alternative value.

The syntax of the ISNULL is provided below:
SELECT ISNULL(expression, alternative_value);

IFNULL is an equivalent function in MySQL.

The definition:
If the expression is NULL, the IFNULL() function returns a specified alternative value. This function returns the expression if it is NOT NULL. This function is typically used to return a different value in the event that a column’s value contains any NULLs.

IFNULL(expression, alternative_value)

SELECT IFNULL(NULL, “bigdatansql.com”);
Result: bigdatansql.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s