웹이야기

[MySQL] FORMAT() 본문

D/MySQL

[MySQL] FORMAT()

yeon.Biju 2020. 4. 13. 11:11

MySQL 문자열 함수와 연산자

 

FORMAT()

   -

 

FORMAT(X, D [,locale])

의 형태

 

Formats the number X to a format like '#, ###,###.##', rounds to D decimal places, and returns the result as a string. If D is 0, the result has no decimal point or fractional part.

 

The optional third parameter enables a locale to be specified to be used for the result number's decimal point, thousands separator, and grouping between separators. Permissible locale values are the same as the legal values for the lc_time_names system variable. If no locale is specified, the default is 'en_US'.

 

mysql> SELECT FORMAT(1232.123456, 4);
+------------------------+
| FORMAT(1232.123456, 4) |
+------------------------+
| 1,232.1235             |
+------------------------+
1 row in set (0.00 sec)

 

mysql> SELECT FORMAT(1232.123456, 0);
+------------------------+
| FORMAT(1232.123456, 0) |
+------------------------+
| 1,232                  |
+------------------------+
1 row in set (0.00 sec)

 

mysql> SELECT FORMAT(1232.123456, 2, 'de_DE');
+---------------------------------+
| FORMAT(1232.123456, 2, 'de_DE') |
+---------------------------------+
| 1.232,12                        |
+---------------------------------+
1 row in set (0.00 sec)


'D > MySQL' 카테고리의 다른 글

[MySQL] HEX()  (0) 2020.04.13
MySQL FROM_BASE64()  (0) 2020.04.13
[MySQL] FIND_IN_SET()  (0) 2020.04.10
[MySQL] FIELD()  (0) 2020.04.08
[MySQL] EXPORT_SET()  (0) 2020.04.08
Comments