Mik*_*ike 56 mysql truncated mysql-error-1292
我不确定这个错误是什么!
#1292 - Truncated incorrect DOUBLE value:
Run Code Online (Sandbox Code Playgroud)
我没有双值字段或数据!
我浪费了整整一个小时试图解决这个问题!
这是我的查询
INSERT INTO call_managment_system.contact_numbers
(account_id, contact_number, contact_extension, main_number, created_by)
SELECT
ac.account_id,
REPLACE(REPLACE(REPLACE(REPLACE(ta.phone_number, '-', ''), ' ', ''), ')', ''),'(','') AS Phone,
IFNULL(ta.ext, '') AS extention,
'1' AS MainNumber,
'2' AS created_by
FROM
cvsnumbers AS ta
INNER JOIN accounts AS ac ON ac.company_code = ta.company_code
WHERE
LENGTH(REPLACE(REPLACE(REPLACE(REPLACE(ta.phone_number, '-', ''), ' ', ''), ')', ''),'(','') ) = 10
Run Code Online (Sandbox Code Playgroud)
这是我的show create table,用于表格的结果
CREATE TABLE `contact_numbers` (
`number_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`account_id` int(10) unsigned NOT NULL DEFAULT '0',
`person_id` int(11) NOT NULL DEFAULT '0',
`contact_number` char(15) NOT NULL,
`contact_extension` char(10) NOT NULL DEFAULT '',
`contact_type` enum('Primary','Direct','Cell','Fax','Home','Reception','Office','TollFree') NOT NULL DEFAULT 'Primary',
`contact_link` enum('Account','PDM','Other') NOT NULL DEFAULT 'Account',
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0 = inactive, 1=active',
`main_number` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1 = main phone number',
`created_on` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`created_by` int(11) NOT NULL,
`modified_on` datetime DEFAULT NULL,
`modified_by` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`number_id`),
KEY `account_id` (`account_id`),
KEY `person_id` (`person_id`)
) ENGINE=InnoDB AUTO_INCREMENT=534 DEFAULT CHARSET=utf8
Run Code Online (Sandbox Code Playgroud)
Bar*_*mar 110
此消息表示您正在尝试比较WHEREor ON子句中的数字和字符串.在您的查询中,唯一可能发生的地方是ON ac.company_code = ta.company_code; 要么确保它们具有类似的声明,要么使用显式CAST将数字转换为字符串.
如果关闭strict模式,则错误应变为警告.
小智 7
我更正了此错误,因为查询中存在语法错误或某些不需要的字符,但MySQL无法捕获它。我and在更新期间在多个字段之间使用,例如
update user
set token='lamblala',
accessverion='dummy' and
key='somekey'
where user = 'myself'
Run Code Online (Sandbox Code Playgroud)
上面的查询中的问题可以通过替换and为逗号(,)来解决
TL; DR
这也可能是由于应用于OR字符串列/文字引起的。
完整版本
对于INSERT涉及视图的简单语句,我收到了相同的错误消息:
insert into t1 select * from v1
Run Code Online (Sandbox Code Playgroud)
尽管所有源列和目标列都是VARCHAR. 经过一番调试,我找到了根本原因;该视图包含以下片段:
string_col1 OR '_' OR string_col2 OR '_' OR string_col3
Run Code Online (Sandbox Code Playgroud)
这大概是以下来自 Oracle 的片段的自动转换的结果:
string_col1 || '_' || string_col2 || '_' || string_col3
Run Code Online (Sandbox Code Playgroud)
(||是 Oracle 中的字符串连接)。解决方案是使用
concat(string_col1, '_', string_col2, '_', string_col3)
Run Code Online (Sandbox Code Playgroud)
反而。
| 归档时间: |
|
| 查看次数: |
134742 次 |
| 最近记录: |