我有A表B表
A表字段 spid spbh
sp001 1001
sp002 1002
sp003 1003B表字段 spid spbh spbh_new
sp001 1001 1011
sp003 1003 1013当b.spid=a.spid 时,更新A表,得出结果
A表 spid spbh
sp001 1011
sp002 1002
sp003 1013这个语句怎么写?
A表字段 spid spbh
sp001 1001
sp002 1002
sp003 1003B表字段 spid spbh spbh_new
sp001 1001 1011
sp003 1003 1013当b.spid=a.spid 时,更新A表,得出结果
A表 spid spbh
sp001 1011
sp002 1002
sp003 1013这个语句怎么写?
set a.spbh=b.spbh_new
from b
where b.spid=a.spid
update a
set a.spbh=b.spbh_new
from a, b
where b.spid=a.spid
update a
set a.spbh=b.spbh_new
from b
where b.spid=a.spid and b.spbh=a.spbh
这个正确,不加and b.spbh=a.spbh的话,sp002的spbh就是null了吧
update A表
set spbh = (select spbh_new from B表 where spid =A表.spid)