执行更新查询后出现问题。它使用所需的描述(字符串)更新我想要的列。但是,不应该受查询影响的列是空白的,而不是具有描述(String)。为了不在这些栏目中行事,我该怎么做?
以下是查询:
update GCCC_ATCOM_CLOSING_REASON_I18N a
set a.DESCRIPTION = (select b.CLOSING_REASON_DESCRIPTION
from GCCC_ATCOM_CLOSING_REASON b
where b.ID_CLOSING_REASON = a.ID_PARENT
AND a.DESCRIPTION ='I HAVE A CAR');
在这种情况下,它只会更新“我有一辆车”描述中的列,但更新后其他列是空白的。
答案 0 :(得分:3)
这是因为您正在更新所有记录,如果描述不是I HAVE A CAR
,则内部查询将返回null。将其更改为:
update GCCC_ATCOM_CLOSING_REASON_I18N a
set a.DESCRIPTION =
(select b.CLOSING_REASON_DESCRIPTION from GCCC_ATCOM_CLOSING_REASON b where b.ID_CLOSING_REASON = a.ID_PARENT)
WHERE a.DESCRIPTION ='I HAVE A CAR'
仅更新描述为I HAVE A CAR