MS-Access:合并下面两个表

时间:2022-06-11 08:18:23

I have two tables in my Access-database. They look something like this:

访问数据库中有两个表。它们看起来是这样的:

Table1
+--------------+----------+----------+----------+
| Kabelnummer  |  Column1 |  Column2 |  Column3 |         
+--------------+----------+----------+----------+
| 1            |    x     |    x     |    x     |
+--------------+----------+----------+----------+
| 2            |    x     |    x     |    x     |
+--------------+----------+----------+----------+
| 3            |    x     |    x     |    x     |
+--------------+----------+----------+----------+
| 4            |    x     |    x     |    x     |
+--------------+----------+----------+----------+

table2
+--------------+----------+----------+----------+
| Kabelnummer  |  Column1 |  Column2 |  Column3 |        
+--------------+----------+----------+----------+
| 1            |    x     |    x     |    x     |
+--------------+----------+----------+----------+
| 2            |    x     |    x     |    x     |
+--------------+----------+----------+----------+
| 3            |    x     |    x     |    x     |
+--------------+----------+----------+----------+
| 4            |    x     |    x     |    x     |
+--------------+----------+----------+----------+

I need a query that gives me 1 table with the data from table1 added to the data from table2:

我需要一个查询,将表1的数据添加到表2的数据中,得到1个表:

TableTotal
+--------------+----------+----------+----------+
| Kabelnummer  |  Column1 |  Column2 |  Column3 | 
+--------------+----------+----------+----------+
| 1            |    x     |    x     |    x     |
+--------------+----------+----------+----------+
| 2            |    x     |    x     |    x     |
+--------------+----------+----------+----------+
| 3            |    x     |    x     |    x     |
+--------------+----------+----------+----------+
| 4            |    x     |    x     |    x     |
+--------------+----------+----------+----------+
| 1            |    x     |    x     |    x     |
+--------------+----------+----------+----------+
| 2            |    x     |    x     |    x     |
+--------------+----------+----------+----------+
| 3            |    x     |    x     |    x     |
+--------------+----------+----------+----------+
| 4            |    x     |    x     |    x     |
+--------------+----------+----------+----------+

The names "Column1", "Column2" and "Column3" are the same in both tables

两个表中的“Column1”、“Column2”和“Column3”的名称是相同的

2 个解决方案

#1


7  

SELECT *
FROM  Table1

UNION

SELECT *
FROM table2;

#2


0  

The question asks for non-distinct values while the current answers provide distinct values. The method below provides non-distinct values such that

这个问题要求非明显的值,而当前的答案提供不同的值。下面的方法提供了非不同的值

SELECT *
FROM  Table1

UNION ALL

SELECT *
FROM table2;

which is often more efficient than the union method, particularly with large data sets (not having to compute the distinct).

这通常比union方法更有效,特别是对于大型数据集(不需要计算不同的数据集)。

#1


7  

SELECT *
FROM  Table1

UNION

SELECT *
FROM table2;

#2


0  

The question asks for non-distinct values while the current answers provide distinct values. The method below provides non-distinct values such that

这个问题要求非明显的值,而当前的答案提供不同的值。下面的方法提供了非不同的值

SELECT *
FROM  Table1

UNION ALL

SELECT *
FROM table2;

which is often more efficient than the union method, particularly with large data sets (not having to compute the distinct).

这通常比union方法更有效,特别是对于大型数据集(不需要计算不同的数据集)。