Sql nested statement reports an error

the database uses MySQL, to concatenate a SQL query statement, and the question mark in the statement is the parameter, but when testing the SQL statement, writing down the three parameters to update the data does not work. How should the correct SQL be written?

the contents of the data table are as follows:

The

SQL statement is as follows:

update t_account set balance=(
select balance-?
from t_account
where account=?)
where account=?;

the error report is as follows:
[SQL] update t_account set balance= (
select balance-200
from t_account
where account=12345)
where account=12345;
[Err] 1093-You can"t specify target table "taccount`for update in FROM clause

Sql
Mar.04,2021

can be simpler

update t_account set balance=balance-?
where account=?;
Menu