Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Dec 2006
    Posts
    306
    Thanks
    24
    Thanked 0 Times in 0 Posts

    why i can not have value as decimal in my table ?

    Hi;
    why i can not have value as decimal in my table ?

    1) i created a table in mysql.

    create table mytable(id smallint auto_increment primary key,
    price decimal)

    Then i tried to insert value like 7.99, but final result for the price in my table is 7, not 7.99. Could you help me, please.

    mysql_query("INSERT INTO mytable (price)
    VALUES ('7.99")");

  • #2
    Regular Coder
    Join Date
    Dec 2006
    Posts
    306
    Thanks
    24
    Thanked 0 Times in 0 Posts
    Thanks a lot, i have solved th problem already.

  • #3
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    For future reference, SMALLINT fields can only whole integers.

    To hold a float value, it must be FLOAT, DOUBLE, or DECIMAL.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •