How can I print the integer part of a number with commas separating every three digits?
12345 -> 12,345 1234.567 -> 1,234.567
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. It only takes a minute to sign up.Sign up to join this community
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