user222427
user222427

Reputation:

mysql select int as currency or convert int to currency format?

Is there a way to convert an int while selecting to an currency format. I can concat the '$' symbol but how do you place the ,'s in? Like turning int =1000 into $1,000?

Or there is one function that can do it all? Is there a string replacement?

Upvotes: 40

Views: 72179

Answers (1)

gregjor
gregjor

Reputation: 22992

FORMAT() function: http://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_format

SELECT CONCAT('$', FORMAT(val, 2)) ... ;

Upvotes: 84

Related Questions