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 卻不報錯,就不知道爲何了

相關文章
相關標籤/搜索