Decimals in Mysql

Post here if you need help with SQL.
Post Reply
wizzuriz
Posts: 53
Joined: Mon Jul 25, 2011 4:22 pm

Decimals in Mysql

Post 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.
bowersbros
Posts: 534
Joined: Thu May 05, 2011 8:19 pm

Re: Please help me. Decimals in Mysql

Post 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)

I don't like to brag, but I wasn't circumcised. I was circumnavigated. ;)

Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
wizzuriz
Posts: 53
Joined: Mon Jul 25, 2011 4:22 pm

Re: Decimals in Mysql

Post 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
Last edited by jacek on Mon Aug 15, 2011 11:21 pm, edited 1 time in total.
Reason: code tags...
bowersbros
Posts: 534
Joined: Thu May 05, 2011 8:19 pm

Re: Decimals in Mysql

Post 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
I don't like to brag, but I wasn't circumcised. I was circumnavigated. ;)

Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Post Reply