468,550 Members | 2,517 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,550 developers. It's quick & easy.

Handling Decimal format

thatos
105 100+
I have the following create statement
Expand|Select|Wrap|Line Numbers
  1. $query = "CREATE TABLE P(
  2.  code int(2) NOT NULL,
  3.  value decimal(3.6) NOT NULL,
  4.  PRIMARY KEY(code)
  5.  
  6. ";
  7.  
but when I look at the data field using phpadmin, value is (3.0) , and when I insert a value say "123.123456" this number gets converted to 123.

I just want to know how to represent a decimal in an sql statement for mysql
Oct 22 '11 #1

✓ answered by johny10151981

Please read the syntax in the documentation
Syntax for Decimal

Name DECIMAL(M,D) // M>=D

3 2288
johny10151981
1,059 1GB
the correct syntax is value decimal(3,6) not 3.6
Oct 24 '11 #2
thatos
105 100+
When I do that, the table is not created, look at the code below.
Expand|Select|Wrap|Line Numbers
  1. $Isotope = "CREATE TABLE Isotope (
  2.     isotope_id int(2) NOT NULL auto_increment,
  3.     isotope_name varchar(50) NOT NULL,
  4.     state int(1) NOT NULL,
  5.     unit varchar(10) NOT NULL,
  6.     min_value decimal(3,6) NOT NULL,
  7.     max_value decimal(3,6) NOT NULL,
  8.     PRIMARY KEY (isotope_id)
  9. )";
  10. $results = mysql_query($Isotope);
  11.  
Oct 24 '11 #3
johny10151981
1,059 1GB
Please read the syntax in the documentation
Syntax for Decimal

Name DECIMAL(M,D) // M>=D
Oct 24 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Paul Sullivan | last post: by
1 post views Thread by | last post: by
6 posts views Thread by Brent Burkart | last post: by
reply views Thread by kreed | last post: by
2 posts views Thread by Sarath | last post: by
1 post views Thread by UniDue | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.