将列表组合为另一个列表中的字段值

时间:2015-04-03 13:20:53

标签: sql list ms-access

我知道我应该有某种想法或者开始在这里发帖以获得帮助;但是,如果有方法/方法可以做到这一点,我就完全迷失了。我希望在MS Access或具有MS Access用户界面的SQL中执行此操作。 我提供了一个表格,其中包含以下字段。 Customer_Code留空。然后我提供了一个Customer_Code列表:可能是1,可能很多。我需要从 List2 <自动填充 List1 ,字段 Customer_Code / b>

列表1 - 当前状态

 Record Type    Customer_Code     Product          Label_ID     Label_Desc      Product_Desc
 ABC                              Product 1        3            Short_Desc      Long Desc
 ABC                              Product 2        3            Short_Desc      Long Desc
 ABC                              Product 3        3            Short_Desc      Long Desc
 ABC                              Product 4        3            Short_Desc      Long Desc

LIST2

 Customer_Code
 12345GR
 78901ZX
 54321RG
 10987XZ

未来/期望的状态

 Record Type    Customer_Code     Product          Label_ID     Label_Desc      Product_Desc
 ABC            12345GR           Product 1        3            Short_Desc      Long Desc
 ABC            12345GR           Product 2        3            Short_Desc      Long Desc
 ABC            12345GR           Product 3        3            Short_Desc      Long Desc
 ABC            12345GR           Product 4        3            Short_Desc      Long Desc
 ABC            78901ZX           Product 1        3            Short_Desc      Long Desc
 ABC            78901ZX           Product 2        3            Short_Desc      Long Desc
 ABC            78901ZX           Product 3        3            Short_Desc      Long Desc
 ABC            78901ZX           Product 4        3            Short_Desc      Long Desc
 ABC            54321RG           Product 1        3            Short_Desc      Long Desc
 ABC            54321RG           Product 2        3            Short_Desc      Long Desc
 ABC            54321RG           Product 3        3            Short_Desc      Long Desc
 ABC            54321RG           Product 4        3            Short_Desc      Long Desc
 ABC            10987XZ           Product 1        3            Short_Desc      Long Desc
 ABC            10987XZ           Product 2        3            Short_Desc      Long Desc
 ABC            10987XZ           Product 3        3            Short_Desc      Long Desc
 ABC            10987XZ           Product 4        3            Short_Desc      Long Desc

到目前为止,我所拥有的只是一个简单的查询 UPDATE [List1], [Customer_Code] SET [List1].[Customer_Code] = [List2]. [Customer_Code];

1 个答案:

答案 0 :(得分:1)

Marciej回答了我的问题。这很简单;我在想这个: 简单选择查询:

SELECT t1.*, t2.* FROM List1 As t1, List2 as t2