简体   繁体   English

仅从新数据库中获取新数据并插入旧数据库

[英]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.

相关问题 将数据从旧的Access数据库传输到新的 - Transfer data from old Access database to new 用来自不同数据库的新表数据更新旧表数据 - Update old table data with new table data from different database 仅从数据库检索新数据 - Retrieve New Data Only From Database 从旧的MySQL数据库中恢复数据到新的Mac OSX中 - Recovering data from old MySQL Database into a new one Mac OSX 如何将大量数据从旧数据库迁移到新数据库 - How to migrate large amounts of data from old database to new 将具有平面数据的旧数据库复制到具有规范化数据的新数据库 - Copying old database with flat data to a new database with normalized data MySQL时间序列数据库,跟踪数量/价格/数据历史记录-仅当新值与上一个不同时才插入新行吗? - MySQL time series database, track quantity/price/data history — insert a new row only if a new value is different from the previous one? 如何在sql insert语句中将旧表的数据转移到数据库中的新表后删除 - How to delete the data of old table after transferred to new table in a database in sql insert statement 在数据库表中的旧记录之后插入新记录 - insert a new record just after a old record in a database table 在 Oracle 数据库中插入、删除、更新返回旧值和新值的触发器 - Trigger for insert, delete, update returning old & new value in Oracle Database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM