【发布时间】:2014-04-16 07:33:56
【问题描述】:
我在对 SQLite 数据库执行某些更新时遇到了问题。我正在使用适用于 Windows 的 SQLite 3 shell。 我正在运行以下命令:
update resovled_chrom_counts set genus =
case resolved_name_full
when resolved_name_full is not null and resolved_name_full != ''
then substr(resolved_name_full,0,instr(resolved_name_full,' ')-1)
else
substr(original_name,0,instr(original_name,' ')-1)
end;
它似乎适用于大多数行,但有些只是在其属字段中以空值结束。我尝试使用此表的“id”字段手动检查其中一些。例如,我发现 id='kew-1' 的行在其属字段中为空,并运行以下查询:
select substr(resolved_name_full,0,instr(resolved_name_full,' ')-1)
from resovled_chrom_counts
where id='kew-1';
令我惊讶的是,我得到了一个结果(不为空)!
看起来查询在“select”语句下有效,但在“update”语句下无效。
谁能给出解释和/或解决方案?
任何帮助,将不胜感激。谢谢!
【问题讨论】:
-
表中的实际值是多少?
-
不确定我理解你的意思,但是对于我提到的行(id='kew-1'),resolved_name_full 字段中的值是'Abelmoschus esculentus (L.) Moench',所以当运行'select'语句时我得到'Abelmoschus',但是在执行更新命令时,属字段设置为null。
标签: sqlite