look at all this numbers in mysql!

Discussion in 'MySQL' started by falcondriver, Apr 26, 2006.

  1. #1
    i have a problem with mysql her. had a ms-access database before, but i need all data in mysql now because an access .mdb-file is not the best choice for a shop system.
    i found a nice tool (navicat) to export this whole .mdb to mysql without any accident.
    now i have this new field with the content of an item, which can be anything between 0.0012 and 900 and im not sure about the right datatype. its "decimal" at the moment (length 8, zerofill off, unsigned on, null allowed), but it "zerofills" the whole number now, so i get results like "0.50000" (0.5 is what i need).
    so whats the right datatype for this?
     
    falcondriver, Apr 26, 2006 IP
  2. drewbe121212

    drewbe121212 Well-Known Member

    Messages:
    733
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    125
    #2
    go with a double,
    if the range can be anywhere from 0.0012 - 900, then



    datatype: FLOAT
     
    drewbe121212, Apr 26, 2006 IP
  3. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'd keep it as decimal, or you could try float if you want. And why does it matter if it's 0.50000 or 0.5 they are equivalent.
     
    exam, Apr 26, 2006 IP
  4. falcondriver

    falcondriver Well-Known Member

    Messages:
    963
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    145
    #4
    because "0.50000 l" dosnt looks very professional on a shopping cart. is there some kind of string function to cut the last zeros?
     
    falcondriver, Apr 26, 2006 IP
  5. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #5
    number_format ($number, 2);
    PHP:
    Which will give you 0.50 which looks better than 0.5
     
    exam, Apr 26, 2006 IP
  6. drewbe121212

    drewbe121212 Well-Known Member

    Messages:
    733
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    125
    #6
    Exam, quick question on the DECIMAL type.

    I was under the impression that Decimal was a fixed decimal point and stored as a string. Wouldn't that mean that if specified lets say 5,2 each number would have to be 234*.11 (at a max length)?
     
    drewbe121212, Apr 27, 2006 IP
  7. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Yes, you've pretty much got it:
     
    exam, Apr 27, 2006 IP