更新一列:
update mytab a set name=(select b.name from goal b where b.id=a.id)
where exists (select 1 from goal b where b.id=a.id);
更新多列:
update mytab a
set (name,address)=(select b.name,b.address
from goal b
where b.id=a.id)
where exists (select 1
from goal b
where b.id=a.id )
特别是要注意exists后面的语句:)这会让目标行不至于为NULL
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12361284/viewspace-349/,如需转载,请注明出处,否则将追究法律责任。