LPAD Function - Oracle to MySQL Migration

In Oracle, the LPAD function returns the string left-padded to the specified number of characters. LPAD accepts 2 or 3 parameters in Oracle.

MySQL also provides the LPAD function, but it requires 3 parameters, so when converting Oracle LPAD with 2 parameters, you have to add ' ' as the 3rd parameter in MySQL.

Oracle:

  -- Pad string with blanks (default) 
  SELECT LPAD('abc', 7) FROM dual;
  #        abc
 
  -- Pad string with * 
  SELECT LPAD('abc', 7, '*') FROM dual;
  # ****abc

MySQL:

  -- Pad string with blanks (3rd parameter must be specified) 
  SELECT LPAD('abc', 7, ' ');
  #        abc
 
  -- Pad string with * 
  SELECT LPAD('abc', 7, '*');
  # ****abc

For more information, see Oracle to MySQL Migration.