update A set A.c1=(select B.c3 from B where B.c3 is not null and B.c4 is not null), set A.c2=(select B.c4 from B where B.c3 is not null and B.c4 is not null)
我看应该这样吧, 假设A表和B表通过id关联查询 select case when b.c3 is not null then b.c3 else a.c1 end c1, case when b.c4 is not null then b.c4 else a.c2 end c2 from a left join b on a.id=b.id
set A.c1=(select B.c3 from B where B.c3 is not null and B.c4 is not null),
set A.c2=(select B.c4 from B where B.c3 is not null and B.c4 is not null)
假设A表和B表通过id关联查询
select case when b.c3 is not null then b.c3 else a.c1 end c1,
case when b.c4 is not null then b.c4 else a.c2 end c2
from a
left join b on a.id=b.id