现在又两个表分别是A表( a ,b , c ,d , e ,f) B表(a,b,c,d)现在点击同步按钮,将A表的数据复制到B表,A,B两个同字段的,数据使用A表的数据(A,B当然通过主键关联),如果说A.a = B.a 剩下A表的数据要全部插入到B表!
6 回答
喵喔喔
TA贡献1735条经验 获得超5个赞
update set B b=A.b,c=A.c,d=A.d from A where B.a=A.a insert into B(a,b,c,d) select A.a,A.b,A.c,A,d from A where A.a not in(select a from B)
for c in (select a,b,c,d from A left join B on A.a=B.a) loop update B set b=c.b,c=c.c,d=c.d where a=c.a; end loop;
insert into B(a,b,c,d) select A.a,A.b,A.c,A,d from A where A.a not in(select a from B);
喵喵时光机
TA贡献1846条经验 获得超7个赞
update set B b=A.b,c=A.c,d=A.d from A where B.a=A.a insert into B(a,b,c,d) select A.a,A.b,A.c,A,d from A where A.a not in(select a from B)
for c in (select a,b,c,d from A left join B on A.a=B.a) loop update B set b=c.b,c=c.c,d=c.d where a=c.a; end loop;
insert into B(a,b,c,d) select A.a,A.b,A.c,A,d from A where A.a not in(select a from B);
- 6 回答
- 0 关注
- 794 浏览
添加回答
举报
0/150
提交
取消