我对更复杂的SQL很新,并且无法正确更新此代码
$sql = "UPDATE bank_accounts
SET bank_accounts.balance = bank_accounts.balance - upgrades.cost
FROM upgrades
INNER JOIN upgrades AS u
WHERE u.id = :id
AND
bank_accounts.uid = :uid"
;
答案 0 :(得分:0)
一些事情......
试试这个吗?
$sql = "UPDATE bank_accounts
SET bank_accounts.balance = bank_accounts.balance - u.cost
FROM upgrades u INNER JOIN bank_accounts
ON u.id = back_accounts.id";
另一个想法...... 更新让我感到紧张,所以我总是喜欢在进行更新之前对数据进行SELECT。
SELECT bank_accounts.balance as BEFORE, bank_accounts.balance - u.cost as AFTER
FROM bank_accounts, upgrades u
ON u.id = bank_accounts.id