问题是从同时拥有贷款和储蓄帐户的储蓄帐户余额中扣除1%的服务费。
架构为
“分支”表(分支名称,分支城市,资产)
“客户”表(客户名称,客户街道,客户城市)
“帐户”表(帐户编号,分支名称,余额)
“贷款”表(贷款编号,分支名称,金额)
“存款人”表(客户名称,帐户编号)
“借款人”表(客户名称,贷款编号)
我尝试过此操作
:update account
-> set balance=balance*0.99
-> where (select distinct customer_name from
->borrower where customer_name in(select
->customer_name from depositor));
但出现错误1242。有人可以帮我吗?
答案 0 :(得分:0)
表帐户没有对customer_name的任何引用。
尝试这样
update account set balance=balance*99 where account_number in (select account_number from depositor);
答案 1 :(得分:0)
请使用INNER JOIN代替where子句。
update account
-> set balance=balance*0.99
-> where (select distinct borrower.customer_name from
->borrower INNER JOIN depositor ON borrower.customer_name = depositor.customer_name));