如何合并两个数据库,具有相同的数据,但具有不同的PK,没有重复的字段? [英] How to merge two databases, with same data, but with different PKs, without duplicated fields?

查看:116
本文介绍了如何合并两个数据库,具有相同的数据,但具有不同的PK,没有重复的字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个mdb文件。
如果需要,我也可以将其转换为MySQL数据库。

I have two mdb files. I can also convert it to MySQL database, if necessary.

如何将这两个不同的dbs合并为一个?

How can I merge these two different dbs to a single one?

这个想法是获取所有信息形式的dbs和合并成一个,不重复任何客户端。
问题是两个bds有相同的客户端,不同的客户端,但客户端的PK不一样。

The idea is to get all info form both dbs and merge into one, without duplicating any client. The problem is that both bds have the same clients, and different ones, but the PKs of the clients aren't the same on them.

每行有一个独特的字段,我猜它可以帮助不知何故。

Every line has a unique field, I guess it can help somehow. Any idea of how can I do that?

推荐答案

选择一个 UNION 除了PK之外的所有列都只会向您提供不同的行:

Select a UNION all columns except the PKs will give you only distinct rows:

insert into new_table (<non-pk columns>)
select <non-pk columns> from tableA
union
select <non-pk columns> from tableB

注意: union 删除重复项。

这篇关于如何合并两个数据库,具有相同的数据,但具有不同的PK,没有重复的字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆