L
lily
Unregistered / Unconfirmed
GUEST, unregistred user!
现在有两个数据表tempsale和annual,现在我想用annual表(nf、yf、spdm、wtsl都是该表中的字段)中满足nf1=<nf<=nf2,yf1<=yf<=yf2,并且annual表的spdm字段值与tempsale表的spdm字段值相同的记录的sum(wtsl)更新tempsale表的相同spdm字段值的记录的wtsl(spdm,wtsl都是tempsale表中的字段).我在query使用如下SQL语句,结果出错,请各位指教一下:
update tempsale
set wtsl=(select sum(annual.wtsl)
from annual
where tempsale.spdm=annual.spdm
and (nf>=:nf1) and (nf<=:nf2)
and (yf>=:yf1) and (yf<=:yf2))
from tempsale,annual
update tempsale
set wtsl=(select sum(annual.wtsl)
from annual
where tempsale.spdm=annual.spdm
and (nf>=:nf1) and (nf<=:nf2)
and (yf>=:yf1) and (yf<=:yf2))
from tempsale,annual