0

问题是从有贷款和储蓄账户的储蓄账户余额中扣除 1% 的服务费。

架构是

“分支”表(分支名称、分支城市、资产)

“客户”表(客户名称、客户街道、客户城市)

“账户”表(account_number、branch_name、balance)

“贷款”表(loan_number、branch_name、amount)

“存款人”表(customer_name,account_number)

“借款人”表(customer_name、loan_number)

我试过这个:

update account
-> set balance=balance*0.99

-> where (select distinct customer_name from 

->borrower where customer_name in(select 

->customer_name from depositor));

但收到错误 1242。有人可以帮我解决这个问题吗?

4

2 回答 2

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));
于 2018-06-27T11:02:31.143 回答
0

表帐户没有对 customer_name 的任何引用。

像这样试试

update account set balance=balance*99 where account_number in (select account_number from depositor); 
于 2018-06-27T08:45:34.283 回答