如何将同一个表中的4个字段连接(或附加)到MS Access中的1个字段中

时间:2009-11-23 22:31:34

标签: ms-access

我有下表:

Source Plate1   Plate2   Plate3   Plate4

我想转换到这个表:

Source Plate1
Source plate2
source Plate3
source Plate4

所以基本上将4 Plate字段中的所有数据附加到1列

我如何在ms access中执行此操作?

感谢

1 个答案:

答案 0 :(得分:3)

您可以使用Union查询,例如:

INSERT INTO NewTable (Source, Plate)
SELECT Source, Plate FROM
  (SELECT Source, Plate1 As Plate FROM Table
   UNION ALL 
   SELECT Source, Plate2 As Plate FROM Table
   UNION ALL 
   SELECT Source, Plate3 As Plate FROM Table
   UNION ALL 
   SELECT Source, Plate4 As Plate FROM Table) As t
编辑:联盟本身就是:

   SELECT Source, Plate1 As Plate FROM Table
   UNION ALL 
   SELECT Source, Plate2 As Plate FROM Table
   UNION ALL 
   SELECT Source, Plate3 As Plate FROM Table
   UNION ALL 
   SELECT Source, Plate4 As Plate FROM Table

或者

 SELECT Source, Plate FROM 
  (SELECT Source, Plate1 As Plate FROM Table
   UNION ALL 
   SELECT Source, Plate2 As Plate FROM Table
   UNION ALL 
   SELECT Source, Plate3 As Plate FROM Table
   UNION ALL 
   SELECT Source, Plate4 As Plate FROM Table) As s