上边的是sql server 语句的写法。
在ACCESS中,我查到的UPDATE的写法是 UPDATE B1 A ,B2 B SET A.NAME=B.NAME WHERE A.ID=B.ID
我按照上边的SQL SERVER 语句对应修改的ACCESS语句如下:
update pp1 z ,
(select JH,XJXH,TGMC,uploadflag,
(select SUM(iif(isnull(b.cd),0,b.cd)) as cd
from pp1 b inner join pp1 d on b.jh=d.jh
where b.xjxh<=d.xjxh AND B.XJXH>0
AND B.TGMC=d.TGMC )
+iif(isnull(( SELECT c.XS FROM pp1 C inner join pp1 e on C.JH=e.JH
where C.XJXH=0 AND C.TGMC=e.TGMC )),0)
AS XS
from pp1) x set z.xs=x.xs where z.jh=x.jh and z.xjxh=x.xjxh
and z.tgmc=x.tgmc and z.xjxh>=0 and z.uploadflag='1'
在这个SQL 语句中,如果将最外层的update语句去掉,即 用“+”号两侧的内容作为xs字段的内容
select JH,XJXH,TGMC,uploadflag,
(select SUM(iif(isnull(b.cd),0,b.cd)) as cd
from pp1 b inner join pp1 d on b.jh=d.jh
where b.xjxh<=d.xjxh AND B.XJXH>0
AND B.TGMC=d.TGMC )
+iif(isnull(( SELECT c.XS FROM pp1 C inner join pp1 e on C.JH=e.JH
where C.XJXH=0 AND C.TGMC=e.TGMC )),0)
AS XS
from pp1可以成功执行。
是不是UPDATE 语句中表B2的位置不能是复杂的SQL语句啊,怎么才能让它不出错呢。各位大侠们帮帮忙吧。