Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change decimal separator in MySQL

Tags:

Is it possible to change the decimal comma from "." (dot) to other character (comma) in MySQL output? I don't want to use functions like FORMAT, I just want to use all the queries I normaly use without any modification. I'm looking for some setting (of some variable, locale etc.). I tried to search the manual but without success.

like image 608
Tomas Avatar asked Dec 29 '11 14:12

Tomas


People also ask

How do I fix decimal places in MySQL?

MySQL ROUND() Function The ROUND() function rounds a number to a specified number of decimal places.

How do you change the decimal point separator?

Click File > Options. On the Advanced tab, under Editing options, clear the Use system separators check box. Type new separators in the Decimal separator and Thousands separator boxes. Tip: When you want to use the system separators again, select the Use system separators check box.

How do I change the decimal separator in SQL Server?

SQL Fiddle Demo You can first replace thousand separator comma(,) to a Zero length string (''), and then you can replace Decimal('. ') to comma(',') in the same select statement.

How do I add a thousand separator in MySQL?

MySQL FORMAT function examples As you see in the result, the de_DE locale use dot (.) for grouping thousand and comma (,) for decimal mark.


2 Answers

Tip for CSV exports: SELECT REPLACE(CAST(prijs_incl AS CHAR), '.', ',') will give you input that can be used as numeric fields in european excelsheets.

like image 115
Ome Ko Avatar answered Sep 27 '22 23:09

Ome Ko


No, you can't. That's the SQL standard and MySQL complies with it (in that point at least).

The problem is not really with output (as you mention, there are various FORMAT functions in most DBMSs) but with INSERT. If you could use comma , for example as decimal point (that's common in other locales) which is aslo used as values separator, Inserts would become ambiguous. See my answer in the question: insert-non-english-decimal-points-in-mysql

like image 28
ypercubeᵀᴹ Avatar answered Sep 28 '22 00:09

ypercubeᵀᴹ