mysql - Truncated incorrect DOUBLE value: 'undefined'

mysql - Truncated incorrect DOUBLE value: 'undefined'

 

我是怎么遇到这个问题的?mysql

        我要从多个表里,查询统计数据,保存到统计表里,须要执行下面这种结构的 sql 语句:sql

                insert into table1 select (select count(*) from t1 where ...) c1, select (select count(*) from t1 where ...) c1spa

        单独执行 select (select count(*) from t1 where ...) c1, select (select count(*) from t1 where ...) c1 没有问题table

        合在一块儿执行就会出现 Truncated incorrect DOUBLE value: 'undefined'select

 

最后发现缘由,是由于:统计

        子语句 select count(*) from t1 where ... 的 where 条件里,有个   where lat != 0数据

        而 t1 表里,lat 保存的是 varchar 格式,当 lat 有转不了 DOUBLE 的值时,就会报错:Truncated incorrect DOUBLE value: 'undefined'查询

 

解决方式:tab

        将 where lat != 0 改为 where lat != '0'co

 

至于为何单独执行 select (select count(*) from t1 where ...) c1, select (select count(*) from t1 where ...) c1 却不报错,就不知道为何了

相关文章
相关标签/搜索