Page 1 of 1

Decimals in Mysql

Posted: Sun Aug 14, 2011 10:49 pm
by wizzuriz
Hello all.

I like to hear if there is anyone that can help me, I need to store values with up to 4 decimals. ( example: 0.0098 or 0.9831 )

I am trying to do some big calculation and need the values to be exact like I type them in.

Please let me know if you can help me out.

Best regards
Wizzuriz.

Re: Please help me. Decimals in Mysql

Posted: Mon Aug 15, 2011 6:56 am
by bowersbros
In the values area, when you set the length (assuming your using phpMyAdmin) then you add it like so:

2,4 to allow up to -99.9999 - 99.9999

If doing it with SQL code then use this:

field_name DECIMAL(2,4)


Re: Decimals in Mysql

Posted: Mon Aug 15, 2011 2:59 pm
by wizzuriz
CREATE TABLE  `testbase`.`testtable` (
`id` INT NOT NULL ,
field_name DECIMAL(2,4) `male` INT NOT NULL
) ENGINE = MYISAM ;
Can you please show me a query where you type in the field_name.

Thanks for the help mann,

Best regards
Wizzuriz

Re: Decimals in Mysql

Posted: Tue Aug 16, 2011 5:00 pm
by bowersbros
wizzuriz wrote:
CREATE TABLE  `testbase`.`testtable` (
`id` INT NOT NULL ,
`field_name` DECIMAL(2,4),
`male` INT NOT NULL
) ENGINE = MYISAM ;
Can you please show me a query where you type in the field_name.

Thanks for the help mann,

Best regards
Wizzuriz
Fixed it in the quote