2015-04-16 54 views
0

我正在嘗試使用此選擇語句並使用它將結果插入到新表中。在插入語句中使用左連接MsAccess

INSERT INTO [DataALL] 
SELECT * 
FROM (SELECT [Data 2015].[Sort ID], 
[Data 2015].[Sort ID Description], 
[Data 2015].[Customer], 
[Data 2015].[Customer ID], 
[Data 2015].[Invoice Nbr], 
[Data 2015].[Src Sys], 
[Data 2015].[HCC], 
[Data 2015].[Bill Lvl 1], 
[Data 2015].[Bill Lvl 2], 
[Data 2015].[Bill Lvl 3], 
[Data 2015].[Bill Lvl 4], 
[Data 2015].[EID], 
[Data 2015].[HCID], 
[Data 2015].[Last Name], 
[Data 2015].[First Name], 
[Data 2015].[Incurred Date], 
[Data 2015].[Paid Date], 
[Data 2015].[Claim Nbr], 
[Data 2015].[Servc Plan], 
[Data 2015].[TOC], 
[Data 2015].[Sex Rel], 
[Data 2015].[Reimburse Amount], 
[EE Status Desc].[Employee Status Desc], 
[Operating Company Mapping].[NiSource_CPG] 

FROM ([Data 2015] 
LEFT JOIN [EE Status Desc] 
ON MID([Data 2015].[Bill Lvl 2],3,1) = [EE Status Desc].[Employee Status]) 
LEFT JOIN [Operating Company Mapping] 
ON MID([Data 2015].[Bill Lvl 4],2,2) = [Operating Company Mapping].[Operating Company]); 

回答

0

嘗試增加你要插入的列:(他們是在下面的第一行的括號)

INSERT INTO [DataALL] ([Sort ID], [Sort ID Description], ...) 
SELECT [Data 2015].[Sort ID], ... FROM [Data 2015] 
LEFT JOIN [EE Status Desc] 
ON MID([Data 2015].[Bill Lvl 2],3,1) = [EE Status Desc].[Employee Status]) 
LEFT JOIN [Operating Company Mapping] 
ON MID([Data 2015].[Bill Lvl 4],2,2) = [Operating Company Mapping].[Operating Company]); 
+0

感謝@Barett爲您解決!我現在碰到一個錯誤,說我無法打開數據庫「 – Malcolm

+0

非常感謝@Barett!我重新壓縮了我的數據庫,一切正常!非常感謝! – Malcolm