MySQL FORMAT() Function

The FORMAT() function formats a number with commas and rounds to a given number of decimal places, returning the result as a string.

Tutorials dojo strip

MySQL FORMAT Function Syntax

SQL

MySQL FORMAT Function Example

This query formats the number 250500.5634 to two decimal places with commas.

SQL

Note: This example does not work in SQLite or the TechKubo Playground. FORMAT() is only supported in MySQL.

MySQL FORMAT Function Parameters

ParameterDescription
numberRequired. The number to be formatted
decimal_placesRequired. Number of decimal places for the result

MySQL FORMAT Function Table Column Example

This query would format a numeric column with two decimals.

SQL

Note: This example does not work in SQLite or the TechKubo Playground. FORMAT() is not supported.

MySQL FORMAT Function Notes

  • Returns the formatted number as a string.
  • Only supported in MySQL (not in SQLite or the TechKubo Playground).
  • Using it in SQLite/TechKubo will result in an error.

Tutorials dojo strip