我在MYSQL的同一个数据库中有2个表,我想将table1中的columnA插入到table2中的columnA,我的条件是table1.name是否等于table2.name。我尝试过,但没有成功
INSERT INTO Table2 (solId, openTime, closingTime, guid)
SELECT solId, openTime, closingTime, guid
FROM Table1
WHERE Table2.name = Table1.name;
最佳答案
您可能需要更新
:
update table2 t2 join
table1 t1
on t1.name = t2.name
set t2.solId = t1.solId,
t2.openTime = t1.openTime,
t2.closingTime = t1.closingTime,
t2.guid = t1.guid;
关于mysql - 如果表1有共同点,如何将数据插入到表2?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55337106/