你這個(gè)報(bào)錯(cuò),說(shuō)白了就是當(dāng)a.值1等于b.值1的時(shí)候,查出來(lái)的值2有多個(gè)結(jié)果,數(shù)據(jù)庫(kù)直接懵了,不知道該用哪個(gè)更新。
如果邏輯不復(fù)雜的話(huà),可以這么寫(xiě):
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,看具體想取啥。要是規(guī)則更復(fù)雜就得另說(shuō)啦~
如果邏輯不復(fù)雜的話(huà),可以這么寫(xiě):
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,看具體想取啥。要是規(guī)則更復(fù)雜就得另說(shuō)啦~