IFNULL

The IFNULL function returns the first nonnull expression.


IFNULL Syntax

IFNULL is identical to the COALESCE scalar function except that IFNULL is limited to two arguments instead of multiple arguments.

Example:

The following example returns 0 if the value in the SALARY column from the table EMPLOYEE is NULL.

   
SELECT EMPL_NAME, IFNULL(SALARY,0)
     FROM EMPLOYEE;

The above example returns the following.


EMPL_NAME, 
BUMRAH , 50000
CEASAR , 20000
ELICA , 0
DEV , 25000
NEWTON , 75000
SAMUEL , 75000
ELICA , 0