UPDATE a
SET a.num = ( SELECT b.nnnum FROM b WHERE a.id = b.id and b.id is not null )
WHERE
EXISTS ( SELECT 1 FROM b WHERE a.num = b.nnnum );
这样写的话 b表为空的话 他直接把a表中的num已经有的值 给制空了 and条件不为空 未生效 麻烦各位指教 谢谢~
UPDATE a
SET a.num = ( SELECT b.nnnum FROM b WHERE a.id = b.id and b.id is not null )
WHERE
EXISTS ( SELECT 1 FROM b WHERE a.num = b.nnnum );
这样写的话 b表为空的话 他直接把a表中的num已经有的值 给制空了 and条件不为空 未生效 麻烦各位指教 谢谢~
UPDATE 表A a
SET a.num = ( SELECT b.nnnum FROM 表B b WHERE a.id = b.id)
WHERE
EXISTS ( SELECT 1 FROM 表B b WHERE a.id = b.id and b.nnnum is not null);