Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert non-English decimal points in mysql

Tags:

php

mysql

How can you make mysql understand non-English decimal points in integer/float fields?

setLocale(LC_ALL, 'da_DK.ISO-8859-1');

eg:

0,25 will be inserted as 0
0.25 will be inserted as 0.25
like image 824
clarkk Avatar asked Jul 08 '11 16:07

clarkk


2 Answers

One of the reasons you can't do that is that the comma , is used for separating field-values in INSERT statements.

INSERT INTO a(b,c) VALUES (3,4,5) would be ambiguous.

Should it result into b=3.4 , c=5 or b=3 , c=4.5 ?

like image 146
ypercubeᵀᴹ Avatar answered Nov 14 '22 04:11

ypercubeᵀᴹ


Numbers aren't affected by locale settings (same in SQL Server too).

So you'd have to send as "0.25"

like image 36
gbn Avatar answered Nov 14 '22 05:11

gbn