我有一个很长的脚本,导入csv文件到一个持有表,做一些消息,然后从持有表复制数据到最终表。
当我运行脚本时,除了第494行,所有内容都执行:
UPDATE `database`.`holding`
SET `rcnt_rslts`=TRUE
WHERE `test_rcnt`=TRUE
AND (`rcntrslt`='pos' OR `rcntrslt`='neg' OR `rcntrslt`='indeterminate');
rcnt_rslts
在两个表中都是BOOL
/TINYINT(1)
,上面和下面的行几乎相同,执行得很好。脚本中没有其他地方引用rcnt_rslts
(用find/replace验证)。
如果我将这行直接插入CMI,它就可以工作了。
是否有行/大小限制,mysql只是随机选择一行忽略?
edit:脚本运行后,rcnt_rslts
中的所有值都是NULL
好的,我试试:
1-也许你在rcntrslt
中打错了,像这样做,你只列出一次。
UPDATE `database`.holding
SET rcnt_rslts=TRUE
WHERE test_rcnt=TRUE
AND (rcntrslt IN ('pos','neg','indeterminate'));
2- =
可以区分大小写,LIKE
不可以,试试:
UPDATE `database`.holding
SET rcnt_rslts=TRUE
WHERE test_rcnt=TRUE
AND (rcntrslt LIKE 'pos' OR rcntrslt LIKE 'neg' OR rcntrslt LIKE 'indeterminate');
3- rcntrslt
还能有哪些值,你不能反转所有的测试?
UPDATE `database`.holding
SET rcnt_rslts = TRUE
WHERE test_rcnt<>FALSE AND test_rcnt IS NOT NULL
AND (rcntrslt NOT IN ('othervalue','test1','gdsd')
AND rcntrslt IS NOT NULL;
4-可能在rcntrslt
中有一些污染导致空格或其他不可打印的字符在那里。
UPDATE `database`.holding
SET rcnt_rslts=TRUE
WHERE test_rcnt=TRUE
AND (rcntrslt LIKE '%pos%' OR rcntrslt LIKE '%neg%'
OR rcntrslt LIKE '%indeterminate%');
5-如果你想调试,你总是可以在那里做一些诊断select来看看发生了什么。
CREATE TABLE log (
id integer auto_increment not null primary key,
logtime timestamp,
reason varchar(255) not null,
tablename varchar(255) not null,
fieldnames varchar(10000) not null,
values varchar(10000) not null,
INDEX log_time (logtime),
INDEX log_table (tablename),
INDEX log_reason (tablename, reason)) ENGINE = InnoDB;
INSERT INTO log (reason, tablename, fieldnames, values)
SELECT
'all values','holding', 'test_rcnt,rcntrslt'
, CONCAT(IFNULL(test_rcnt,'NULL'), ',' ,IFNULL(rcntrslt,'NULL')
FROM holding;
INSERT INTO log (reason, tablename, fieldnames, values)
SELECT
'test_rcnt = TRUE','holding', 'test_rcnt,rcntrslt'
, CONCAT(IFNULL(test_rcnt,'NULL'), ',' ,IFNULL(rcntrslt,'NULL')
FROM holding
WHERE test_rcnt = TRUE;
等。
现在检查日志,看看出了什么问题。