Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql视图上的查询工作不正常_Mysql_Sql_Database - Fatal编程技术网

Mysql视图上的查询工作不正常

Mysql视图上的查询工作不正常,mysql,sql,database,Mysql,Sql,Database,我在一个视图上运行了一个非常简单的查询,它使用一个值,而不使用所有其他值。我试图从视图中选择具有不同索引值的行,仅索引1.5返回结果 以下是视图表的示例 我有这个观点,伊森 select * from easylens +---+----+------+----+-----+-----+-----+-------+--------+ |id |type|design|name|brand|index|color|coating|material| +---+----+------+----+-

我在一个视图上运行了一个非常简单的查询,它使用一个值,而不使用所有其他值。我试图从视图中选择具有不同索引值的行,仅索引1.5返回结果

以下是视图表的示例

我有这个观点,伊森

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 |
+---+----+------+----+-----+-----+-----+-------+--------+
MySQL returned an empty result set (i.e. zero rows). (Query took 0.0002 sec)
但是当我跑的时候

select * from easylens where `index`=1.6
我明白了

+---+----+------+----+-----+-----+-----+-------+--------+
|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 |
+---+----+------+----+-----+-----+-----+-------+--------+
MySQL returned an empty result set (i.e. zero rows). (Query took 0.0002 sec)
浮动的危险(精度和比例未定义)

试着投

SELECT * FROM easylens WHERE CAST(`index` as DECIMAL) = CAST(1.6 as DECIMAL);

索引
字段的数据类型是什么?@Sadikhasan索引字段是FLOAT将其更改为十进制-或者它可能足以定义浮点中的精度和比例-但我不确定这篇文章为什么会有帮助。它不是关于铸造,而是关于指定长度十进制(m,D)FLOAT(m,D)不太有效