![](/img/trans.png)
[英]Cursor is storing values in a variable but not updating in another table Sql Server
[英]sql updating values according to same variable in another table
我想根据表B的新值更新“ area”变量的值
我的尝试:
update a set area=(select area from b)
where a.id=b.id
表A
Id area
1 N
2 S
3 W
4 W
5 E
表B
Id area
1 W
2 E
应该这样做:
update a
set area = b.area
from a
join b
on a.id = b.id;
试试这个
Update a set area= COALESCE((select b.area from b where a.id=b.id),a.area);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.