这个查询有什么问题?
update TA,TB
set TA.change = 1,TA.value = TB.value
where
TA.name = TB.name and TA.value <> TB.value
我想在结核病价值变化时从TB更新TA
答案 0 :(得分:0)
您的查询没问题。我会用明确的join
编写它:
update TA join
TB
on TA.name = TB.name
set TA.change = 1,
TA.value = TB.value
where TA.value <> TB.value;
您可能需要考虑NULL
个值:
update TA join
TB
on TA.name = TB.name
set TA.change = 1,
TA.value = TB.value
where not (TA.value <=> TB.value);