在包含一些用于测试的字段的表格中,我们可以选择field
= 0.0但不是<> 0.0
表格内容:
| id | lower_name | sphinx_internal_id | sphinx_internal_class | sphinx_deleted | latt | lngt | status_hash | uploaded_as_hash | wifi |
| 119626 | lekarna novo mesto | 23925 | Spot | 0 | 0.000000 | 0.400000 | 75439824 | 21396735 | 0 |
| 119627 | lekarna novo mesto | 23925 | Spot | 0 | 0.000000 | 1.700000 | 75439824 | 21396735 | 0 |
2 row in set (0.00 sec)
示例输出:
> SELECT * FROM `spot_core`, `spot_delta` WHERE `latt` = 0.0;
| id | lower_name | sphinx_internal_id | sphinx_internal_class | sphinx_deleted | latt | lngt | status_hash | uploaded_as_hash | wifi |
| 119626 | lekarna novo mesto | 23925 | Spot | 0 | 0.000000 | 0.000000 | 75439824 | 21396735 | 0 |
1 row in set (0.00 sec)
> SELECT * FROM `spot_core`, `spot_delta` WHERE `latt` <> 0.0;
ERROR 1064 (42000): sphinxql: NEQ filter on floats is not (yet?) supported near '0.0'
> SELECT * FROM `spot_core`, `spot_delta` WHERE `latt` != 0.0;
ERROR 1064 (42000): sphinxql: NEQ filter on floats is not (yet?) supported near '0.0'
> SELECT * FROM `spot_core`, `spot_delta` WHERE `latt` != 0;
Empty set, 1 warning (0.00 sec)
> SELECT * FROM `spot_core`, `spot_delta` WHERE `latt` <> 0;
Empty set, 1 warning (0.00 sec)
答案 0 :(得分:1)
可以做到
SELECT *,IF(latt<>0.0,1,0) AS myint FROM `spot_core`, `spot_delta` WHERE myint = 1;
IF()函数实现比较浮点数所需的阈值。