Name

FORMAT()

Synopsis

FORMAT(number, decimal)

This function returns the given floating-point number 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 rounds the number given to two decimal places.

Get MySQL in a Nutshell, 2nd Edition 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.