我在 mysql 数据库中有两个表:
1) dotable_new;
2) dotable_new_new
现在我需要将表 dotable_new 中的值 TOTAL 更新为表 dotable_new_new 中的值 TOTAL。
我正在尝试此更新查询,但没有成功...你能帮助我吗?
UPDATE dotable_new a, dotable_new_new tmp
SET a.total = tmp.total
WHERE
a.rdt IN ('tot mac')
dotable_new;
+---------+---------------+--------+-------+----+
| RDT | TYPE | NUMBER | TOTAL | ID |
+---------+---------------+--------+-------+----+
| tot mac | tot | 3209 | 3249 | 1 |
+---------+---------------+--------+-------+----+
dotable_new_new
+---------+-------+----+
| RDT | TOTAL | ID |
+---------+-------+----+
| tot mac | 10899 | 5 |
+---------+-------+----+
最佳答案
检查这对您有帮助 how to join two tables in update
尝试一下:
UPDATE dotable_new a
INNER JOIN dotable_new_new tmp ON tmp.rdt = a.rdt
SET a.total = tmp.total
WHERE a.rdt = 'tot mac'
关于mysql - 在 MySql 中更新连接两个表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22737345/