Query matching fails with = but works with LIKE
Date: November 03, 2009 02:45PM
I have a table called "static" with two fields, X and Y (location fields, if it matters). Both are DOUBLE.
iorder is another double field which is X*Y and UNIQUE. It is also classified as PRIMARY KEY.
Several other table have the iorder field. I want to join ID from static to these other fields based on iorder.
mysql> select ID,X,Y,iorder from static limit 20;
+----+----------------+---------------+-------------------+
| ID | X | Y | iorder |
+----+----------------+---------------+-------------------+
| 1 | -115.407893246 | 51.1130871371 | -5898.85370379193 |
| 2 | -115.404323145 | 51.1130384642 | -5898.66560784535 |
| 3 | -115.400753055 | 51.1129896823 | -5898.47750022987 |
| 4 | -115.397182975 | 51.1129407914 | -5898.28938089553 |
| 5 | -115.393612905 | 51.1128917916 | -5898.10124985504 |
| 6 | -115.390042844 | 51.1128426828 | -5897.91310704692 |
| 7 | -115.386472794 | 51.1127934651 | -5897.7249525861 |
| 8 | -115.432808191 | 51.1156720358 | -5900.42556566256 |
| 9 | -115.429237849 | 51.1156241217 | -5900.23753454379 |
| 10 | -115.425667516 | 51.1155760988 | -5900.04949166888 |
| 11 | -115.422097193 | 51.1155279668 | -5899.8614370555 |
| 12 | -115.418526881 | 51.1154797258 | -5899.67337076746 |
| 13 | -115.414956578 | 51.1154313759 | -5899.48529271524 |
| 14 | -115.411386285 | 51.115382917 | -5899.29720293958 |
| 15 | -115.407816001 | 51.1153343492 | -5899.10910140207 |
| 16 | -115.404245728 | 51.1152856724 | -5898.92098819457 |
| 17 | -115.400675465 | 51.1152368866 | -5898.73286326712 |
| 18 | -115.397105212 | 51.1151879918 | -5898.5447266209 |
| 19 | -115.393534968 | 51.1151389881 | -5898.3565782175 |
| 20 | -115.389964735 | 51.1150898754 | -5898.16841814876 |
+----+----------------+---------------+-------------------+
20 rows in set (0.00 sec)
mysql>
mysql> select ID from static where iorder=-5898.16841814876;
Empty set (0.30 sec)
mysql> select ID from static where iorder='-5898.16841814876';
Empty set (0.05 sec)
mysql> select ID from static where iorder="-5898.16841814876";
Empty set (0.05 sec)
mysql> select ID from static where iorder LIKE -5898.16841814876;
+----+
| ID |
+----+
| 20 |
+----+
1 row in set (0.25 sec)
Why does LIKE work but not =?
Using LIKE makes the query run really really slow.
= should be faster but it simply does not match.
Thanks!
Sorry, only registered users may post in this forum.
© 1995-2008 MySQL AB, 2008- Sun Microsystems, Inc.