有表
A:
a bB:
c dC:
e f查找表A所有记录
aList = select a,b from A//遍历表A所有结果
for each aItem in aList
begin //aItem.a 为A表中其中一条的a
select sun(f) from C where e in (select c from B where d = aItem.a)end怎样写成一条语句,就是sun(f)不用每个循环都查一次DB,
怎样跟select a,b from A 并在一起
A:
a bB:
c dC:
e f查找表A所有记录
aList = select a,b from A//遍历表A所有结果
for each aItem in aList
begin //aItem.a 为A表中其中一条的a
select sun(f) from C where e in (select c from B where d = aItem.a)end怎样写成一条语句,就是sun(f)不用每个循环都查一次DB,
怎样跟select a,b from A 并在一起
from a
join
(
select b.d,sum(c.f) f
from B
join C on B.c=C.e
Group by B.d
) t on a.a=t.d
from a
left join
(
select b.d,sum(c.f) f
from B
join C on B.c=C.e
Group by B.d
) t on a.a=t.d