我试图获取一个SQL查询,在我的网站上一次更新每个银行帐户。
UPDATE
bank_accounts
SET bank_accounts.balance = bank_accounts.balance * XI.incomeX
FROM
bank_accounts BA
INNER JOIN
users XI
ON
BA.uid = XI.uid
那就是SQL 数据库看起来像
+-----+----------+
| uid | balance |
+-----+----------+
| 1 | 200 |
| 2 | 2200 |
| 3 | 89189 |
| 4 | 12834894 |
+-----+----------+
+-----+---------+
| uid | incomeX |
+-----+---------+
| 1 | 2 |
| 2 | .4 |
| 3 | 9000 |
| 4 | 14 |
+-----+---------+
SQL查询根本没有更新任何内容。
答案 0 :(得分:1)
尝试
UPDATE
bank_accounts
INNER JOIN
users XI
ON
bank_accounts.uid = XI.uid
SET bank_accounts.balance = bank_accounts.balance * XI.incomeX
答案 1 :(得分:0)
您是否尝试使用选择进行更新?如果是这样,你就错过了选择
SET bank_accounts.balance = SELECT bank_accounts.balance * XI.incomeX