Octavian,

> mysql> create table test(id float);
> mysql> insert into test values(1.123), (3.1495);
> mysql> select * from test where id=1.123;
> Empty set (0.00 sec)
> Shouldn't this last query show me the record that has the id=1.123?

Well ... 1.123 is greater than 1.123, see:

mysql> select id from octavian where id > 1.123;
+--------+
| id     |
+--------+
|  1.123 |
| 3.1495 |
+--------+
2 rows in set (0.00 sec)

Now here's why. Floats are simply not precise:

mysql> select id*10000 from octavian where id > 1.123;
+-----------------+
| id*10000        |
+-----------------+
| 11230.000257492 | <----------
| 31494.998931885 |
+-----------------+
2 rows in set (0.00 sec)

> What query should I use to do this?

I leave this one to Paul or one of the other gurus.

Regards,
--
  Stefan Hinz <[EMAIL PROTECTED]>
  Geschäftsführer / CEO iConnect GmbH <http://iConnect.de>
  Heesestr. 6, 12169 Berlin (Germany)
  Tel: +49 30 7970948-0  Fax: +49 30 7970948-3

----- Original Message -----
From: "Octavian Rasnita" <[EMAIL PROTECTED]>
To: "MySQL" <[EMAIL PROTECTED]>
Sent: Monday, January 20, 2003 9:34 AM
Subject: Is it normal?


> Hi all,
>
> I've tried the following SQL queries:
>
> mysql> create table test(id float);
> Query OK, 0 rows affected (0.00 sec)
>
> mysql> insert into test values(1.123), (3.1495);
> Query OK, 2 rows affected (0.01 sec)
> Records: 2  Duplicates: 0  Warnings: 0
>
> mysql> select * from test where id=1.123;
> Empty set (0.00 sec)
>
> Shouldn't this last query show me the record that has the id=1.123?
>
> What query should I use to do this?
>
> Thank you.
>
>
>
> Teddy,
> Teddy's Center: http://teddy.fcc.ro/
> Email: [EMAIL PROTECTED]
>
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to