我想根据表B的新值
更新“area”变量的值我的尝试:
<link href="http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<div id="container" class="resizable">
<div id="handle" class="ui-resizable-handle ui-resizable-n">
<div>content</div>
</div>
</div>
表A
update a set area=(select area from b)
where a.id=b.id
表B
Id area
1 N
2 S
3 W
4 W
5 E
答案 0 :(得分:3)
这应该这样做:
update a
set area = b.area
from a
join b
on a.id = b.id;
答案 1 :(得分:1)
试试这个
Update a set area= COALESCE((select b.area from b where a.id=b.id),a.area);