4

How can I print the integer part of a number with commas separating every three digits?

For example,

 12345    -> 12,345
 1234.567 -> 1,234.567
18

Use the FORMAT function, which works for floating point numbers as well as for integers:

Floating point numbers:

mysql> SELECT FORMAT(12332.123456, 4);
        -> '12,332.1235'
mysql> SELECT FORMAT(12332.1,4);
        -> '12,332.1000'
mysql> SELECT FORMAT(12332.2,0);
        -> '12,332'

Integers:

mysql> SELECT FORMAT(12334, 0);
        -> 12,334
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.