[英]Get only new data from new database and insert into old database
I have 2 exported database from magento 1我有 2 个从 magento 1 导出的数据库
1- today's database (NEW) 2- Old database (OLD) 1- 今天的数据库 (NEW) 2- 旧的数据库 (OLD)
what I want is get all new data from new database to old database我想要的是从新数据库中获取所有新数据到旧数据库
for example, last order ID in old database is 131 and last order ID in new database is 161. I want to inset new order Id (from 132 to 161) in old database.例如,旧数据库中的最后一个订单 ID 是 131,新数据库中的最后一个订单 ID 是 161。我想在旧数据库中插入新的订单 ID(从 132 到 161)。
This will be applicable to all entity like (order,product,customer)这将适用于所有实体,如(订单、产品、客户)
a general solution for all table will be appreciate Thanks in advance!所有表的通用解决方案将不胜感激提前谢谢!
I got solution:我得到了解决方案:
First we need to select unique data from new table and insert it into old table by:首先,我们需要 select 新表中的唯一数据并将其插入到旧表中:
INSERT INTO DB1.tb (select * from DB2.tb where sku not in(Select sku from DB1.tb)); INSERT INTO DB1.tb(从 DB2.tb 中选择 *,其中 sku 不在(从 DB1.tb 中选择 sku));
Where:在哪里:
DB1 - Old Database DB1 - 旧数据库
DB2 - New database DB2 - 新数据库
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.