select a.aid, b.name,c.age
from aa a (nolock)
inner join bb b (nolock) on a.aid=b.aid
inner join ff f (nolock) on b.bid=f.bid
inner join cc c (nolock) on f.cid=c.cid
where c.name='tpa'

şimdi böyle bi sorguyla üç kolon geliyor bununla birlikte şuna benzer bi update işlemi yapmam lazım:

update
(select a.aid, b.name,c.age
from aa a (nolock)
inner join bb b (nolock) on a.aid=b.aid
inner join ff f (nolock) on b.bid=f.bid
inner join cc c (nolock) on f.cid=c.cid
where c.name='tpa'
)
set c.name='xxx' where b.bid=111

c ile b arasında bi bağlantı yok. sorabildim mi bilmiyorum ama nasıl yaparım bunu?

 

ilk cektigin sorguna x deyip, sadece o sorgudan cektigin degerleri update edebilirsin, kosul olarak da ayni sekilde, sadece ordan cektiklerine kosul verebilrisin;

update
(select a.aid, b.name,c.age
from aa a (nolock)
inner join bb b (nolock) on a.aid=b.aid
inner join ff f (nolock) on b.bid=f.bid
inner join cc c (nolock) on f.cid=c.cid
where c.name='tpa'
) x
set x.name='xxx' where x.bid=111

bu update'i kayitlar coklandigi icin oracle yapmaz, her durumda yapmasini istersen, su hint'i eklemen lazim '/*+ BYPASS_UJVC */', yani soyle olur;

update /*+ BYPASS_UJVC */
(select a.aid, b.name,c.age
from aa a (nolock)
inner join bb b (nolock) on a.aid=b.aid
inner join ff f (nolock) on b.bid=f.bid
inner join cc c (nolock) on f.cid=c.cid
where c.name='tpa'
) x
set x.name='xxx' where x.bid=111

nawres

update cc
set cc.name = 'xxx'
from aa
join bb on aa.aid=bb.aid
join ff on bb.bid=ff.bid
join cc on ff.cid=cc.cid
where cc.name = 'tpa' and bb.bid = 111

gibi bir şey olur sanırım.

ocanal
1

mobil görünümden çık