合并Access中的两个表? [英] Merging two tables in Access?
问题描述
我有两个表,这些表具有需要合并的不同数据.它们确实具有相似之处,例如:订单号,名称,类型或产品.但是它们也有单独的数据,例如:订单日期和版画.
I have two tables that have different data that I need to merge. They do have similarities such as: Order number, Name, type or product. But they have separate data as well like: Order date, and Engravings.
我将在Access中将两个单独的Append查询添加到合并表中吗?还是一个追加查询?还是只是将数据分开?
Would I do two separate Append queries in Access into a merged table? Or one Append queries? Or just keep the data separate?
我是Access的新手,正在尝试找到解决此问题的最佳方法.
I am new to Access and trying to find the best way to approach this.
推荐答案
这取决于您要执行的操作.假设您有表A
(具有50条记录)和B
(具有75条)记录,并且两个表都有一个名为OrderID
的相似列.
It depends on what you want to do. Let's assume you have tables A
(with 50 records) and B
(with 75) records, and both tables have a similar column called OrderID
.
附加行:
如果要通过组合A
中的记录(行)和B
中的记录(行)来创建具有125条记录的表,请运行以下两个查询:
Appending Rows:
If you want to create a table with 125 total records by combining records (rows) from A
and records (rows) from B
, run the following two queries:
查询1:
SELECT A.ORDER_NUMBER, A.TEXT_FIELD1 as DATA INTO C
FROM A;
查询2:
INSERT INTO C ( ORDER_NUMBER, DATA )
SELECT B.ORDER_NUMBER, B.TEXT_FIELD2
FROM B;
附加列::如果要创建一个包含75条记录的表,并将A
中的列追加到B
中的列,请运行以下查询:
Appending Columns: If you want to create a table with 75 total records where you are appending columns from A
to the columns in B
, then run the following query:
SELECT B.ORDER_NUMBER, A.TEXT_FIELD1, B.TEXT_FIELD2 INTO C
FROM A RIGHT JOIN B ON A.ORDER_NUMBER = B.ORDER_NUMBER;
...以类似的方式,可以通过运行以下查询将B
中的列追加到新表C
中的A
中的列中,该表总共有50条记录:
... in a similar way, you can append columns in B
to columns in A
in a new table C
with a total of 50 records by running the following query:
SELECT A.ORDER_NUMBER, A.TEXT_FIELD1, B.TEXT_FIELD2 INTO C
FROM A LEFT JOIN B ON A.ORDER_NUMBER = B.ORDER_NUMBER;
这篇关于合并Access中的两个表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!