mySQL and subtracing .5

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nigel

    mySQL and subtracing .5

    I have a number in a INT field in a table and I want to subtract .5 (1/2)
    from the number... ie 4-.5=3.5

    I have tried it in mysql but it does seem to work, can anyone help with the
    query



  • Pedro Graca

    #2
    Re: mySQL and subtracing .5

    Nigel wrote:[color=blue]
    > I have a number in a INT field in a table and I want to subtract .5 (1/2)
    > from the number... ie 4-.5=3.5
    >
    > I have tried it in mysql but it does seem to work, can anyone help with the
    > query[/color]

    What query? ???

    mysql> select id-0.5 from foobar where id<3;
    +--------+
    | id-0.5 |
    +--------+
    | 0.5 |
    | 1.5 |
    +--------+
    2 rows in set (0.00 sec)
    --
    --= my mail box only accepts =--
    --= Content-Type: text/plain =--
    --= Size below 10001 bytes =--

    Comment

    • Tony Marston

      #3
      Re: mySQL and subtracing .5

      Integers by their very definition are whole numbers, therefore decimal
      places cannot be used. If you want decimal places then change the field type
      to FLOAT, REAL, DECIMAL or NUMERIC.

      --
      Tony Marston

      This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL




      "Nigel" <nobody@here.co m> wrote in message
      news:c1qqvg$qoq $1$8302bc10@new s.demon.co.uk.. .[color=blue]
      > I have a number in a INT field in a table and I want to subtract .5 (1/2)
      > from the number... ie 4-.5=3.5
      >
      > I have tried it in mysql but it does seem to work, can anyone help with[/color]
      the[color=blue]
      > query
      >
      >
      >[/color]


      Comment

      Working...