[英]How to insert data from table1 to table2 if they got something in common?
我在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
:
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;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.