Name

FORMAT( )

Synopsis

FORMAT(number, decimal)

This function returns the floating-point number given with a comma inserted between every three digits and a period before the number of decimal places specified in the second argument.

SELECT FORMAT(1000.375, 2)
       AS Amount;
+----------+
| Amount   |
+----------+
| 1,000.38 |
+----------+

Notice that the function rounded the number given to two decimal places.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.