What's wrong in this simple query

Discussion in 'MySQL' started by greatlogix, Aug 4, 2010.

  1. #1
    table:
    CREATE TABLE `am_graph` (
    `id` int(3) unsigned NOT NULL auto_increment,
    `total` decimal(7,2) default NULL,
    `gyear` int(4) default NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

    Insert query:
    INSERT INTO am_graph(total, gyear) VALUES(106229.33, 2010)

    Result is: 3 99999.99 2010

    Total is showing value 99999.99. Can you please tell me whats wrong in my query? Why mysql is not saving actual total (106229.33)?
     
    greatlogix, Aug 4, 2010 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Your total column isn't large enough. 7,2 means 7 digits total with 2 decimals, basically 5 before the decimal, 2 after. You're trying to enter a number that would require 8,2. If you increase to 8,2 or 9,2 it should be fine.
     
    jestep, Aug 4, 2010 IP
  3. greatlogix

    greatlogix Active Member

    Messages:
    664
    Likes Received:
    13
    Best Answers:
    1
    Trophy Points:
    85
    #3
    it worked. Thanks for your help. Some green for you.
     
    greatlogix, Aug 4, 2010 IP