次のようなSQL更新クエリがあります。
update #tree c
set treetop=p.treetop,
treeptag=p.treeptag,
adjust= 'a2a'
from #tree p ,#regions r
where c.treeptag=''
and c.xsreg=r.Region
and c.xsreg <> c.reg
and c.tradedate=p.tradedate
and p.treeaotag=replace(r.srvid+':'+c.tradedate+':'+c.litag,' ','')
次のように、結合を使用して「fromlist」を使用せずにクエリを作成しようとしています。
update #tree c
set treetop=(select p.treetop from #tree p ,#regions r
where c.treeptag=''
and c.xsreg=r.Region
and c.xsreg <> c.reg
and c.tradedate=p.tradedate
and p.treeaotag=replace(r.srvid+':'+c.tradedate+':'+c.litag,' ','')),
treeptag=(select p.treeptag from #tree p ,#regions r
where c.treeptag=''
and c.xsreg=r.Region
and c.xsreg <> c.reg
and c.tradedate=p.tradedate
and p.treeaotag=replace(r.srvid+':'+c.tradedate+':'+c.litag,' ','')),
adjust= 'a2a'
where exists (select 1 from #tree p ,#regions r where c.treeptag=''
and c.xsreg=r.Region
and c.xsreg <> c.reg
and c.tradedate=p.tradedate
and p.treeaotag=replace(r.srvid+':'+c.tradedate+':'+c.litag,' ',''))
ただし、上記のクエリは間違った行数を返すようです。どんな提案でも最も役に立ちます。