3个表a表:
aid
ascore
*******************************************b表:
bid
bpei********************************************c表:
bid
aid
cscore麻烦开始了:如何实现这个update
ascore += bpei * cscore
aid
ascore
*******************************************b表:
bid
bpei********************************************c表:
bid
aid
cscore麻烦开始了:如何实现这个update
ascore += bpei * cscore
set Ascore=cscore +bpei*cscore
FROM A JOIN C ON A.AID=C.AID
JOIN B ON C.BID=B.BID
set Ascore=ascore+bpei*cscore
FROM A JOIN C ON A.AID=C.AID
JOIN B ON C.BID=B.BID修改一楼的
select b.bpei*c.cscore from a,b,c
where a.aid=b.bid=c.cid)
set ascore = isnull((select bpei from b where aid = a.aid),0) + isnull((select ascore from b where bid = a.bid),0)
from c
a
set
ascore=ascore+b.bpei*c.cscore
from
a,b,c
where
a.aid=c.aid
and
b.bid=c.bid
update a set a.ascore=b.bpei*c.cscore
from (select a.ascore,b.bpei,c.cscore from a,b,c where a.aid=b.bid=c.cid) t
set ascore = (select b.bpei * c.cscore from b , c where b.bid = c.bid and c.aid = a.aid)
from a
错误
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to
MYSQL的 不会哦 有请小梁
对啊,是MYSQL的,怎么搞呢?
set ascore = (select b.bpei * c.cscore from b , c where b.bid = c.bid and c.aid = a.aid)
from a
谢谢dawugui,但是存在一点问题,稍微修改一下,正确语句是
set ascore = ascore + (select b.bpei * c.cscore from b , c where b.bid = c.bid and c.aid = a.aid)
结贴!
update a set ascore = ascore + (select b.bpei * c.cscore from b , c where b.bid = c.bid and c.aid = a.aid)
---这个可以不?
update
a
set
ascore=ascore+b.bpei*c.cscore
from
a,b,c
where
a.aid=c.aid
and
b.bid=c.bid