1

我有两个表main_tablenew_data我想通过表中main_table的数据进行更新,因为您可以看到. 它应该由表格中的数据填写。第三张表是结果。什么是最好的解决方案?new_datamain_tablenew_data

main_table
---------------------
id | name     | time
---------------------
 1 | tom      | 60
 2 | daniel   | 30
 3 | monica   | 42
 4 | gabriela | 
 5 | rachel   |
 6 | michael  | 15
 7 | adriana  | 
---------------------

new_data
--------------------
id | name     | time
--------------------
 1 | gabriela | 22
 2 | rachel   | 15
 3 | adriana  | 17
--------------------


main_table - updated by new_data - it should be result
---------------------
id | name     | time
---------------------
 1 | tom      | 60
 2 | daniel   | 30
 3 | monica   | 42
 4 | gabriela | 22
 5 | rachel   | 15
 6 | michael  | 15
 7 | adriana  | 17
---------------------
4

1 回答 1

2
UPDATE new_data t1, JOIN main_table t2
SET t2.Time=t1.Time
WHERE t2.name=t1.name
于 2013-11-05T16:20:58.867 回答