473,395 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 2475
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

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

Similar topics

0
by: Tobias | last post by:
Hi all, is it possible to set decimal-format in any way by using a variable or similar? Example: <xsl:variable name="myseparator" select="@separator"/> <xsl:decimal-format...
10
by: Paul Sullivan | last post by:
decimal d; d = 1.1M OR d= (decimal) 1.1 Discussioon
1
by: | last post by:
Hi all, Is there one operation to do the following more efficiently,need to format upto 500 in one go decimal d; d.ToString("N2").PadLeft(12); thank you.
6
by: Brent Burkart | last post by:
What is the best way to format the data in a textbox into a decimal (#########.##)? Thanks, Brent
3
by: kimi | last post by:
hi all, can anyone tell me how to convert a comp-1 floating point number to a decimal in REXX??
0
by: kreed | last post by:
I am trying to write a script that returns a decimal value where the value in the column is only two characters. The values in the column I am returning are currenlty 4 character AND 2 characters. ...
2
by: Sarath | last post by:
Is it possible to make lexical_cast function to support stirngs wtih '0x' format. e.g boost::lexical_cast<unsigned char>( "0x7E" ) This formatting throws bad_lexical_cast exception. Is there...
1
by: veer | last post by:
hello expert i made a programe in vb6.0 and i want to display the price in decimal format like e.g. 2323.90 i am sending my program line where i want to change the price format ls1Level =...
7
by: Andrus | last post by:
How to create format string for decimal data type which shows blank for zero and default format otherwize ? I tried format string "f;f;#" but this shows f for nonzero numbers. Andrus. ...
2
by: lenniekuah | last post by:
Hullo Friends, I need your help. Please help me. I am using C#NEt2008 to develop Window Application to calculate Monthly Repayment amount of the LOAN amount of 12 months of payment It's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.