原帖由 zxqsharp 于 2008-10-31 18:27 发表
update A
set a = (select b from B where B.c = A.c);
这样写的意思是对A表进行全表update,那么没有匹配上的,则把原来的A表中的a列置null,所以要加上条件:
update a set a.a=(select b.b from b where a.c=b.c) where a.a not in(select a.a from a where not exists(select 1 from b where a.c=b.c));
原帖由 alex613501 于 2008-11-1 21:52 发表
那这么写岂不是更简单?
update a set a.a=(select b.b from b where a.c=b.c)
where a.a exists (select b from a,b where a.c=b.c)
正解~这种方法是目前最简单的一种。