Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
774 views
in Technique[技术] by (71.8m points)

mysql - How to format number with "." as thousand separator, and "," as decimal separator?

how to format number with "." as thousand separator, and "," as decimal separator in MySql?

I'm using Format function like

SELECT Format(myNumber,2) as myNumberFormatted FROM ...

But return type is a number like:

1,000,000.00

instead i want

1.000.000,00

How to do in MySQL ?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

MySQL>=5.5:

SELECT FORMAT(10000000.5, 2, 'de_DE') AS format

MySQL<5.5:

SELECT REPLACE(REPLACE(REPLACE(FORMAT(10000000.5,2), ',', ':'), '.', ','), ':', '.') AS format

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...