Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have the following table:

+------------+--------+------+-----+---------+----------------+
| Field      | Type   | Null | Key | Default | Extra          |
+------------+--------+------+-----+---------+----------------+
| id         | double | NO   | PRI | NULL    | auto_increment |
| az1        | float  | YES  |     | 989898  |                |
| el1        | float  | YES  |     | 989898  |                |
| az2        | float  | YES  |     | 989898  |                |
| el2        | float  | YES  |     | 989898  |                |
| rfs_angle  | float  | YES  |     | 989898  |                |
| scan_speed | float  | YES  |     | 989898  |                |
+------------+--------+------+-----+---------+----------------+

I inserted this data more than 100times

INSERT INTO lidar_traj_table (az1, el1, az2, el2, rfs_angle, scan_speed)  VALUES (49.100, 0.000,989898,8.000,1.0,1.000)

When I'm trying to select the data I'm receiving nothing:

SELECT * FROM lidar_traj_table WHERE az1=49.1

When I'm selecting smaller data then 49.1 than I get all the rows

SELECT * FROM lidar_traj_table WHERE az1<=49.1

Why am I getting empty result for this:

SELECT * FROM lidar_traj_table WHERE az1=49.1
share|improve this question
1  
I think this is a problem with representing float by finite binary. See: this, this. The last one may have a solution. –  m0nhawk Jan 9 '13 at 13:44
3  
add comment

1 Answer

up vote 3 down vote accepted

If you want to store exact values then you should use the DECIMAL data type instead of FLOAT.

share|improve this answer
    
Looks like a comment, but a powerful answer. +1 !!! –  RolandoMySQLDBA Jan 9 '13 at 18:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.