[英]mysql Insert Bulk data from one to another table
nsert Bulk data from one to another table , 将大容量数据从一个表插入另一个表,
master table 主表
column1,col2,col3,col migrated
123 1 1 o
234 2 2 0
child table 子表
col1,col2
123 1
234 2
if i get successful insert data from master table to child table ,i want to update master table migrated column to 1 or other wise i rollback my data from my child table using stored procedure with cursors. 如果我成功地将数据从主表插入到子表中,我想将主表迁移的列更新为1或其他方式,我使用带有游标的存储过程从我的子表中回滚数据。
I don't know about the need for stored procedures and such. 我不知道是否需要存储过程等等。 You can simply update across a join. 您可以简单地在一个联接中进行更新。
UPDATE master AS m
LEFT JOIN child AS c
ON m.column1 = c.col1 AND
m.col2 = c.col2
SET
m.migrated = 1,
c.col1 = m.column1,
c.col2 = m.col2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.