How to insert integer with dot or comma like 3.99

Discussion in 'MySQL' started by deriklogov, Nov 18, 2009.

  1. #1
    Hey,

    I need to insert integer into (int) type field with comma or dot, how to do that ?
    Like 3.99 ?
     
    deriklogov, Nov 18, 2009 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Round it before inserting it.

    If you're using php something like: $insert_int = round($int,0);
     
    jestep, Nov 18, 2009 IP
  3. deriklogov

    deriklogov Well-Known Member

    Messages:
    1,079
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    130
    #3
    but I need to have it in full, I dont need round number.
     
    deriklogov, Nov 18, 2009 IP
  4. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #4
    Multiply by 100, then round to zero. When you extract the info, you need to divide by 100.
     
    jestep, Nov 18, 2009 IP
  5. deriklogov

    deriklogov Well-Known Member

    Messages:
    1,079
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    130
    #5
    to jestep:

    PERFECT idea , thank you so much
     
    deriklogov, Nov 18, 2009 IP
  6. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #6
    This approach will create problems with bigger values like 2147483646.5 for singed int field and 4294967294.9 for unsigned int. Are you going to save that much big vaues?
     
    mwasif, Nov 19, 2009 IP
  7. deriklogov

    deriklogov Well-Known Member

    Messages:
    1,079
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    130
    #7
    no, we wouldnt go so crazy, so we should be set
     
    deriklogov, Nov 19, 2009 IP
  8. chisara

    chisara Peon

    Messages:
    141
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #8
    How to fuck up your schema;
    I want to store a decimal into an int without loosing precision.
    Well you DON'T thats why the DB has an decimal datatype.

    Next you will be putting all you datatypes into a Varchar which is even better minimal datatype usage, minimum data validation rules in effect, maximum side effects.
     
    chisara, Nov 20, 2009 IP
  9. gacba

    gacba Peon

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    This is likely a localization problem. 3,99 is a European style currency display. If the number requires 3.99, that says to me that the localization of the DB is set to something like US, instead of the real target country. That may require a full reinstall of the DB to fix. Check the settings in your control panel.
     
    gacba, Nov 20, 2009 IP