Mysql FORMAT
From w3cyberlearnings
Contents |
MySQL FORMAT Function
This function returns a format number.
Syntax FORMAT
- N: number input
- D: Decimal point
- Locale (optional): Specifies the locale setting, the default is en_US.
FORMAT(N, D, Locale);
Note
Format a string like #,###,###.## (The last two is the decimal point or fractional part, if nothing it fills with all zero).
Example 1: Four decimal point
mysql> SELECT FORMAT(123456,4); +------------------+ | FORMAT(123456,4) | +------------------+ | 123,456.0000 | +------------------+ 1 row in set (0.00 sec)
Example 2
mysql> SELECT FORMAT(123456.432,3); +----------------------+ | FORMAT(123456.432,3) | +----------------------+ | 123,456.432 | +----------------------+ 1 row in set (0.00 sec)
Example 3
mysql> SELECT FORMAT(123456.432,2); +----------------------+ | FORMAT(123456.432,2) | +----------------------+ | 123,456.43 | +----------------------+ 1 row in set (0.00 sec)