表1:
号码 话费 时间
11 10 2004-10-18
11 20 2004-10-18
11 1.3 2004-10-19
表2:
号码 用户 话费合计
11 yhy 30
22 mm 0用一sql语句更新表2。把时间等于2004-10-18的话费加起来放到号码对应的话费合计中。
号码 话费 时间
11 10 2004-10-18
11 20 2004-10-18
11 1.3 2004-10-19
表2:
号码 用户 话费合计
11 yhy 30
22 mm 0用一sql语句更新表2。把时间等于2004-10-18的话费加起来放到号码对应的话费合计中。
set a.话费合计 =
(select sum(话费)
where 号码 = a.号码
and 时间 = '2004-10-18')
update 表2 as a
set a.话费合计 =
(select sum(话费)
from 表1
where 号码 = a.号码
and 时间 = '2004-10-18')
set a.话费合计 =(select sum(话费)
from 表1 b
where b.号码=a.号码 and a.时间 = '2004-10-18')
操作必须使用一个可更新的查询access数据库
set a.话费合计 =(select sum(话费) from 表1 b
where b.号码=a.号码
and b.时间 = '2004-10-18')
SQl 查询分析器测试通过
----------------------------------------------------------------
花自飘零水自流,一种相思,两处闲愁。
此情无计可消除,才下眉头,又上心头。
----------------------------------------------------------------
set a.话费合计 =
(select sum(话费)
from 表1
where 号码 = a.号码
and 时间 = '2004-10-18')
应该是没有问题的。
参考http://community.csdn.net/Expert/topic/3250/3250952.xml?temp=.3120081
-------------------------------------------------------------------------
select 号码,sum(话费) as sumsl from aa into bb where 时间=#2004-10-18# group by 号码;update aa inner join bb
on aa.号码=bb.号码
set aa.话费合计=aa.话费合计+bb.sumsldrop table bb
update 表1 set e=dlookup("编号","表2","b='"&m& "'") where a=m不过感觉没什么用
set a.话费合计 =
(select sum(话费)
form 表1
where 号码 = a.号码
and 时间 = '2004-10-18')
update 表2 a
(select sum(话费) as total
form 表1
where 号码 = a.号码
and 时间 = '2004-10-18') b
set a.话费合计 = b.total
update 表2 a
(select sum(话费) as total
form 表1
where 号码 = a.号码
and 时间 = #2004-10-18#) b
set a.话费合计 = b.total
update 表2 a,
(select sum(话费) total
form 表1 group by 号码
) b
set a.话费合计 = b.total
where b.号码 = a.号码
and b.时间 = #2004-10-18#)
update 表2 a,
(select 号码,sum(话费) total
form 表1 group by 号码
) b
set a.话费合计 = b.total
where b.号码 = a.号码
and b.时间 = #2004-10-18#)
select 号码,sum(话费) as sumsl from aa where 时间=#2004-10-18# group by 号码;-->select 号码,sum(话费) as sumsl into bb from aa into bb where 时间=#2004-10-18# group by 号码;
所有引用的表都列在UPDATE关键字后即可
请再看一下楼主的题:
表1:
号码 话费 时间
11 10 2004-10-18
11 20 2004-10-18
11 1.3 2004-10-19
表2:
号码 用户 话费合计
11 yhy 30
22 mm 0用一sql语句更新表2。把时间等于2004-10-18的话费加起来放到号码对应的话费合计中。
这两个表的关键字段是什么,中间的关联是什么呢。大家说说,如果说出来了我认为问题就可以解决了
我想楼主可能少了表1的一个字段就是“用户”