表ks_pscjjlb:

wKiom1LX7W7gs2LQAABQHJx9Grk775.jpg


表:ks_pscjjlb_temp

wKioL1LX7S-QlD_CAAA8TlPnpwo543.jpg

现在根据ks_pscjjlb_temp表来根据ks_pscjjlb表中的cj字段的值

update ks_pscjjlb p1 set p1.cj=(select cj from ks_pscjjlb_temp p2 where p1.id=p2.id )

where exists(select 1 from ks_pscjjlb_temp p2 where p2.id=p1.id)

更新后的结果为:3条

select * from ks_pscjjlb  显示结果如下:

wKiom1LX7iTQ7Is0AABJ82h5a5w276.jpg

如果update语写成如下:

update ks_pscjjlb p1 set p1.cj=(select cj from ks_pscjjlb_temp p2 where p1.id=p2.id )

更新结果为:4条

更新后select * from ks_pscjjlb  显示结果如下:

wKioL1LX7ragl4yYAABD6JnuOns629.jpg