MySQL IFNULL Function

Example

Return the specified value IF the expression is NULL, otherwise return the expression:

SELECT IFNULL(NULL, "Iampsp.com");

Definition and Usage

The IFNULL() function returns a specified value if the expression is NULL.

If the expression is NOT NULL, this function returns the expression.

Syntax

IFNULL(expression, alt_value)

Continue reading MySQL IFNULL Function

MySQL COALESCE Function

Example

Return the first non-null value in a list:

SELECT COALESCE(NULL, NULL, NULL, 'W3Schools.com', NULL, 'Example.com');

Definition and Usage

The COALESCE() function returns the first non-null value in a list.

Syntax

COALESCE(val1, val2, ...., val_n)

Continue reading MySQL COALESCE Function