0
我試着這樣做查詢,但它不工作...任何一個可以幫助我使用選擇更新查詢中
(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);
,但它提供了一個錯誤
「操作必須使用一個可更新的查詢」
此處有任何更新? – Ramy 2010-12-18 19:29:00
我沒有疑惑你的子選擇,但你確定你不能從JOIN中相關的表中檢索源數據中的值嗎?如果你使用它,你可以嘗試Access/Jet/ACE DISTINCTROW謂詞來試圖強制更新。如果沒有,臨時表可能是唯一的解決方案。 – 2010-12-19 00:59:03