what's wrong with this query?
update TA,TB
set TA.change = 1,TA.value = TB.value
where
TA.name = TB.name and TA.value <> TB.value
I want to update TA from TB when value change in TB
Your query is okay. I would write it with an explicit join
:
update TA join
TB
on TA.name = TB.name
set TA.change = 1,
TA.value = TB.value
where TA.value <> TB.value;
You might need to take NULL
values into account:
update TA join
TB
on TA.name = TB.name
set TA.change = 1,
TA.value = TB.value
where not (TA.value <=> TB.value);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.