mysql comma issue

Discussion in 'MySQL' started by dizyn, Dec 26, 2007.

  1. #1
    Hello,

    I want to show show float and int values with comma in mysql database.

    Like if i enter 1000 or 1000.00 it should take it as 1,000 or 1,000.00

    is there any way to do this?


    thank you
     
    dizyn, Dec 26, 2007 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    no you cannot store.

    While displaying you can format t like this

    Regards

    Alex
     
    kmap, Dec 26, 2007 IP
  3. kendo1979

    kendo1979 Peon

    Messages:
    208
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    mysql can store decimal values you can store 1000.2 or 1000.256 but you can't store 1,000. mysql will store 1000 you can then display it as 1,000 on your script.
     
    kendo1979, Dec 26, 2007 IP
  4. dizyn

    dizyn Active Member

    Messages:
    251
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    what's the method to display 1000 like 1,000?

    thank you
    dizyn
     
    dizyn, Dec 31, 2007 IP
  5. Kuldeep1952

    Kuldeep1952 Active Member

    Messages:
    290
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    60
    #5
    This can be done with mysql FORMAT function using zero decimals.

    SELECT FORMAT(1000,0);
    -> '1,000'
     
    Kuldeep1952, Dec 31, 2007 IP
  6. coches

    coches Peon

    Messages:
    41
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    how about for example

    decimal( 12, 2 )
     
    coches, Dec 31, 2007 IP
  7. kendo1979

    kendo1979 Peon

    Messages:
    208
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    use number format function on php.
     
    kendo1979, Jan 1, 2008 IP