TO_CHAR - Convert Number to String - Oracle to MySQL Migration

In Oracle, TO_CHAR function can convert a numeric value to string using the specified format. In MySQL, you can use FORMAT function as well as other string functions and expressions.

Oracle:

  -- Convert the price to string format
  SELECT TO_CHAR(1000, 'FM$9,999,999') FROM dual;
  # $1,000

MySQL:

  -- Convert the price to string format
  SELECT CONCAT('$', FORMAT(1000, 0));
  # $1,000

Conversion Examples

Typical conversion examples:

Oracle MySQL
TO_CHAR(1000, 'FM$9,999,999') CONCAT('$', FORMAT(1000, 0))
TO_CHAR(1000, '9,999,999') FORMAT(1000, 0)
TO_CHAR(123456, '999,999.9') FORMAT(123456, 1)
TO_CHAR(123456.123, '999,999.9') FORMAT(123456.123, 1)

For more information, see Oracle to MySQL Migration.

You could leave a comment if you were logged in.