你这个报错,说白了就是当a.值1等于b.值1的时候,查出来的值2有多个结果,数据库直接懵了,不知道该用哪个更新。
如果逻辑不复杂的话,可以这么写:
update tab1 a set 值2 = (select min(值2) from tab2 b where a.值1 = b.值1)
where exists (select 1 from tab2 b where a.值1 = b.值1)
and a.值1 in (select 值1 from tab2)
and cop_g_no in (select * from tab3)
这里用了min(值2),你也可以用max,看具体想取啥。要是规则更复杂就得另说啦~
如果逻辑不复杂的话,可以这么写:
update tab1 a set 值2 = (select min(值2) from tab2 b where a.值1 = b.值1)
where exists (select 1 from tab2 b where a.值1 = b.值1)
and a.值1 in (select 值1 from tab2)
and cop_g_no in (select * from tab3)
这里用了min(值2),你也可以用max,看具体想取啥。要是规则更复杂就得另说啦~