Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question

closed as off topic by Mark Storey-Smith, Jon Seigel, Marian, Max Vernon, Aaron Bertrand Apr 7 '13 at 18:41

Questions on Database Administrators Stack Exchange are expected to relate to database administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

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'


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

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