NVL Function - Oracle to MySQL Migration

In Oracle, the NVL function allows you to replace NULL with the specified expression: it returns the first operand if it is not NULL, and the second operand otherwise.

In MySQL you can use the IFNULL function.

Oracle:

  -- Replace NULL
  SELECT NVL('John', 'N/A') FROM dual;
  /* John */
 
  -- Replace NULL
  SELECT NVL(NULL, 'N/A') FROM dual;
  /* N/A */

MySQL:

  -- Replace NULL
  SELECT IFNULL('John', 'N/A');
  /* John */
 
  -- Replace NULL
  SELECT IFNULL(NULL, 'N/A');
  /* N/A */

For more information, see Oracle to MySQL Migration.