oracle update 多表关联如何替换数据?

2025-03-04 13:13:14
推荐回答(2个)
回答1:

哈哈,你犯了逻辑错误,UPDATE table1 a set card_no=8888 WHERE exists (),()中是个Boolean表达式,而不是你先更要条件,就像你写的那么多条件可以用一个表达式来替换那就是(1=1),我说的够明白么,就是说UPDATE table1 a set card_no=8888 WHERE exists (select a.card_no
from tabel1 a,table2 b,table3 c
where b.tran_code=123 and a.person_no=c.person_no and b.tran_code=c.tran_code) 相当于UPDATE table1 a set card_no=8888 WHERE exists (1=1) 你说呢,update table1 set card_no=8888
where card_no in (select a.card_no
from tabel1 a,table2 b,table3 c
where b.tran_code=123 and a.person_no=c.person_no and b.tran_code=c.tran_code) 才是正解

回答2:

update table1 set card_no=8888
where card_no in (select a.card_no
from tabel1 a,table2 b,table3 c
where b.tran_code=123 and a.person_no=c.person_no and b.tran_code=c.tran_code)