IFNULL

The IFNULL function returns the value of the first non-null expression.

Read syntax diagramSkip visual syntax diagramIFNULL(expression ,expression)

The IFNULL function is identical to the COALESCE scalar function with two arguments. For more information, see COALESCE.

Example

  • When selecting the employee number (EMPNO) and salary (SALARY) from all the rows in the EMPLOYEE table, if the salary is missing (that is, null), then return a value of zero.
      SELECT EMPNO, IFNULL(SALARY,0)
        FROM EMPLOYEE