出现mysql错误#1242

dzjeubhm  于 2021-06-24  发布在  Mysql
关注(0)|答案(2)|浏览(335)

问题是从既有贷款又有储蓄账户的储蓄账户余额中扣除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。有人能帮我吗?

ua4mk5z4

ua4mk5z41#

表帐户没有任何对客户名称的引用。
像这样试试

update account set balance=balance*99 where account_number in (select account_number from depositor);
zu0ti5jz

zu0ti5jz2#

请使用内部连接而不是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));

相关问题