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
    New Coder
    Join Date
    Jun 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    float not accept correct update

    have a table donations with the following field:
    amount float(10,2)

    If I have a record with amount = 98765432.00

    and then I try to do the following update:
    UPDATE donations SET amount = "98765430.00" WHERE (donations_id = "31948")

    The update seems to work and there are no errors but when I go to look at the record the amount is still
    98765432.00

    Any ideas? I can't figure out why it's doing this - and sometimes the number is updated but to something other then what was in the update...

    I've tried this with amount decimal(10,2) and have the same problem.

    Thanks in advance.

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,631
    Thanks
    4
    Thanked 147 Times in 138 Posts
    use decimal(10,2) not float. float stores an approximation of the number, decimal stores the number you want it to store.

  • #3
    New Coder
    Join Date
    Jun 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks that worked!
    I tried that once before but I must have done something wrong - but now it's working fine.


  •  

    Posting Permissions

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