A floating point number can never be equal to 12.3.
It can be close, and with rounding display as 12.3, but it
won't actually be equal to 12.3.
Use a decimal type instead.
Jim Dickenson wrote:
>I am running mysql Ver 11.15 Distrib 3.23.47, for pc-linux-gnu (i686)
>installed from a binary RPM file. This is using RedHat Linux 7.2.
>
>I have a table described as:
>mysql> describe junk;
>+--------+---------------+------+-----+---------+-------+
>| Field | Type | Null | Key | Default | Extra |
>+--------+---------------+------+-----+---------+-------+
>| record | decimal(3,0) | YES | | NULL | |
>| title | varchar(250) | YES | | NULL | |
>| num1 | float | YES | | NULL | |
>| num2 | decimal(6,0) | YES | | NULL | |
>| num3 | decimal(10,3) | YES | | NULL | |
>| code | char(3) | YES | | NULL | |
>| sdate | date | YES | | NULL | |
>| stime | time | YES | | NULL | |
>+--------+---------------+------+-----+---------+-------+
>8 rows in set (0.00 sec)
>
>It has the following data:
>mysql> select record,num1 from junk;
>+--------+----------+
>| record | num1 |
>+--------+----------+
>| 1 | 12.3 |
>| 2 | 17.785 |
>| 3 | 138.981 |
>| 4 | -34.12 |
>| 5 | -12.7365 |
>| 6 | -0.34 |
>+--------+----------+
>6 rows in set (0.00 sec)
>
>The following command does not update the row I would like it to:
>mysql> update junk set num1=12.4 where num1=12.3;
>Query OK, 0 rows affected (0.01 sec)
>Rows matched: 0 Changed: 0 Warnings: 0
>
>
>Can I get some insight as to what the problem might be?
>
>Thanks,
>