NVL Function - Oracle to MySQL Migration

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

In MySQL you have to use 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.