我對一個視圖運行一個非常簡單的查詢,它使用一個值,並且不能與其他值一起工作。我試圖從不同的索引值視圖中選擇行只指數1.5返回的結果關於Mysql查詢查詢無法正常工作
以下是查看錶的樣本
我有這種說法easylens
select * from easylens
+---+----+------+----+-----+-----+-----+-------+--------+
|id |type|design|name|brand|index|color|coating|material|
+---+----+------+----+-----+-----+-----+-------+--------+
| 1 | sv |aase |nel |hoya | 1.5|292 |ar |plastic |
+---+----+------+----+-----+-----+-----+-------+--------+
| 2 | sv |base |tel |zeri | 1.5|293 |ar |plastic |
+---+----+------+----+-----+-----+-----+-------+--------+
| 3 | sv |case |fel |essi | 1.5|294 |ar |plastic |
+---+----+------+----+-----+-----+-----+-------+--------+
| 4 | sv |dase |gel |hoya | 1.6|293 |ar |plastic |
+---+----+------+----+-----+-----+-----+-------+--------+
| 5 | sv |fase |rel |essi | 1.6|293 |ar |plastic |
+---+----+------+----+-----+-----+-----+-------+--------+
| 6 | sv |gase |mel |hoya | 1.6|292 |ar |plastic |
+---+----+------+----+-----+-----+-----+-------+--------+
當我運行
select * from easylens where `index`=1.5
我得到
+---+----+------+----+-----+-----+-----+-------+--------+
|id |type|design|name|brand|index|color|coating|material|
+---+----+------+----+-----+-----+-----+-------+--------+
| 1 | sv |aase |nel |hoya | 1.5|292 |ar |plastic |
+---+----+------+----+-----+-----+-----+-------+--------+
| 2 | sv |base |tel |zeri | 1.5|293 |ar |plastic |
+---+----+------+----+-----+-----+-----+-------+--------+
| 3 | sv |case |fel |essi | 1.5|294 |ar |plastic |
+---+----+------+----+-----+-----+-----+-------+--------+
但是當我運行
select * from easylens where `index`=1.6
我得到
MySQL returned an empty result set (i.e. zero rows). (Query took 0.0002 sec)
w^hat是'index'字段的數據類型? – Sadikhasan 2014-09-10 10:51:05
@Sadikhasan索引字段爲float – Bakly 2014-09-10 10:57:31
將其更改爲DECIMAL - 或者它可能足以在FLOAT中定義精度和比例 - 但我不確定爲什麼 – Strawberry 2014-09-10 11:00:20