MySQL database
-
how to make number 56,500,51 in MySQL I tried to make a function in MySQL like this
CREATE FUNCTION `fTITIK`(number double(8,2)) RETURNS VARCHAR(255) CHARSET latin1
DETERMINISTIC
BEGIN DECLARE hasil VARCHAR(255);
SET hasil = REPLACE(REPLACE(REPLACE(FORMAT(number, 2), '.', '|'), ',', '.'), '|', ','); RETURN (hasil);
ENDhen when it starts it only appears 56,500 while the numbers that are behind the comma do not work any suggestion? what should I fix?
-
how to make number 56,500,51 in MySQL I tried to make a function in MySQL like this
CREATE FUNCTION `fTITIK`(number double(8,2)) RETURNS VARCHAR(255) CHARSET latin1
DETERMINISTIC
BEGIN DECLARE hasil VARCHAR(255);
SET hasil = REPLACE(REPLACE(REPLACE(FORMAT(number, 2), '.', '|'), ',', '.'), '|', ','); RETURN (hasil);
ENDhen when it starts it only appears 56,500 while the numbers that are behind the comma do not work any suggestion? what should I fix?
It looks like the value represents a floating point number (or currency. If that's the case, don't store it as a string. The app that uses the data is responsible for correctly formatting the value for display purposes.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
how to make number 56,500,51 in MySQL I tried to make a function in MySQL like this
CREATE FUNCTION `fTITIK`(number double(8,2)) RETURNS VARCHAR(255) CHARSET latin1
DETERMINISTIC
BEGIN DECLARE hasil VARCHAR(255);
SET hasil = REPLACE(REPLACE(REPLACE(FORMAT(number, 2), '.', '|'), ',', '.'), '|', ','); RETURN (hasil);
ENDhen when it starts it only appears 56,500 while the numbers that are behind the comma do not work any suggestion? what should I fix?
Do your data formatting in the user interface (that includes reports). NEVER do it in the database and as John said never store your numbers as strings ALWAYS use the correct data format. This also applies to dates, store them as DATE or DATETIME, never as strings.
Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP
-
It looks like the value represents a floating point number (or currency. If that's the case, don't store it as a string. The app that uses the data is responsible for correctly formatting the value for display purposes.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
Do your data formatting in the user interface (that includes reports). NEVER do it in the database and as John said never store your numbers as strings ALWAYS use the correct data format. This also applies to dates, store them as DATE or DATETIME, never as strings.
Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP