我有两张桌子,看起来都像
I have two tables, both looking like
id name value
===================
1 Joe 22
2 Derk 30
我需要根据每个表中的检查名称将value
的值从tableA
复制到tableB
.
I need to copy the value of value
from tableA
to tableB
based on check name in each table.
对于这个 UPDATE
语句有什么提示吗?
Any tips for this UPDATE
statement?
除了这个答案,如果您需要根据 tableA.value 动态更改 tableB.value,您可以这样做,例如:
In addition to this answer if you need to change tableB.value according to tableA.value dynamically you can do for example:
UPDATE tableB
INNER JOIN tableA ON tableB.name = tableA.name
SET tableB.value = IF(tableA.value > 0, tableA.value, tableB.value)
WHERE tableA.name = 'Joe'
这篇关于mysql 使用另一个表中的值更新列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!