access查询两列信息合并输出,合并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.

Would I do two separate Append queries in Access into a merged table? Or one Append queries? Or just keep the data separate?

I am new to Access and trying to find the best way to approach this.

解决方案

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.

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:

Query 1:

SELECT A.ORDER_NUMBER, A.TEXT_FIELD1 as DATA INTO C

FROM A;

Query 2:

INSERT INTO C ( ORDER_NUMBER, DATA )

SELECT B.ORDER_NUMBER, B.TEXT_FIELD2

FROM 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;

... 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;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值