【发布时间】:2010-12-18 17:11:25
【问题描述】:
我试过做这个查询,但它不起作用...谁能帮帮我
(SELECT (r.fare-r.fare*(t.discount/100)) FROM ccard AS c, downer AS d,
typepolicy AS t,
rates AS r
WHERE c.cardno=Enter_card_no and d.deviceno=Enter_device_no and
d.routeno=r.routeno and c.type=t.type );
UPDATE bank
SET amount = amount-[the_result of above select query]
WHERE accountno=(select c.accountno from ccard c where cardno=Enter_card_no);
所以我试着做
UPDATE bank
SET amount = amount-(SELECT (r.fare-r.fare*(t.discount/100)) FROM ccard AS c,
downer AS d, typepolicy AS t, rates AS r
WHERE c.cardno=Enter_card_no and d.deviceno=Enter_device_no and
d.routeno=r.routeno and c.type=t.type )
WHERE accountno=(select c.accountno from ccard c where cardno=Enter_card_no);
但它给出了一个错误
“操作必须使用可更新的查询”
【问题讨论】:
-
我没有弄明白你的子选择,但你确定你不能从 JOIN 相关的表中的源数据中检索值吗?如果您使用它,您可以尝试使用 Access/Jet/ACE DISTINCTROW 谓词来尝试强制更新。否则,临时表可能是唯一的解决方案。