MySQL error 1292 数据类型错误

匿名 (未验证) 提交于 2019-12-02 22:02:20

Mysql [Err] 1292 - Truncated incorrect DOUBLE value: 'a'

A-01. 问题:

 [SQL] update `book` set `times` = 1 where `type` = 1 and `times` = 0; [Err] 1292 - Truncated incorrect DOUBLE value: 'a'

A-02. 分析


该错误为类型错误, 查询条件 `times`=0 的结果集中含有 `type`='a' 的结果, 所有类型转换错误.

A-03. 解决

 [SQL] update `book` set `times` = 1 where `type` = '1' and `times` = 0;

 ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

B-01. 查看 sql_mode

 [SQL] show session variables like '%sql_mode%'; +---------------+--------------------------------------------+ | Variable_name | Value                                      | +---------------+--------------------------------------------+ | sql_mode      | STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION | +---------------+--------------------------------------------+ 1 row in set (0.00 sec)

B-02. 问题

 [SQL] update `user` set `name` = CONCAT("用户", `yy_id`) where `name` = `yy_id`; [ERR] 1292 - Truncated incorrect DOUBLE value: '蔡徐坤'

B-03. 解决

设置 sql_mode 为非严格模式, 问题解决

 [SQL] set sql_mode = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; Query OK, 0 rows affected (0.00 sec)   [SQL] show session variables like '%sql_mode%'; +---------------+--------------------------------------------+ | Variable_name | Value                                      | +---------------+--------------------------------------------+ | sql_mode      | NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION | +---------------+--------------------------------------------+ 1 row in set (0.00 sec)   [SQL] update `user` set `name` = CONCAT("用户", `yy_id`) where `name` = `yy_id`; Query OK, 101622 rows affected, 14594 warnings (2.65 sec) Rows matched: 101622  Changed: 101622  Warnings: 14594

文章来源: https://blog.csdn.net/hkk666123/article/details/90635005
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!