2017-07-23 103 views
0

我在MS Access中編寫了一個查詢,當我嘗試運行此查詢時出現錯誤。我找不到它的問題。MSAccess中的查詢表達式中的語法錯誤(缺少運算符)

SELECT 
p.[ID] as [ID], 
p.[Code] as [CODE], 
p.[DESCRIPTION] as [DESCRIPTION], 
p.[Coloring] as [Coloring], 
p.[Sizing] as [Sizing], 
p.[BarCode] as [Barcode], 
p.[PartsNo] as [PartsNo], 
p.[HSN_SAC] as [HSN_SAC], 
p.[GSTRate] as [GSTRate], 
p.[Remarks] as Remarks, 
c.[CODE] as [CategoryCode], 
c.[Description] as [CategoryDescription], 
b.[CODE] as [BrandCode], 
b.[Description] as [BrandDescription], 
s.[Id] as [SupplierId], 
s.[Code] as [SupplierCode], 
s.[Description] as [SupplierDescription] 
FROM [PRODUCTMASTER] p LEFT JOIN [CATEGORYMASTER] c on p.[CategoryId] = c.[ID] 
LEFT JOIN [BRANDMASTER ] b on p.[BrandId] = b.[ID] 
LEFT JOIN [SUPPLIERAMSTER] s on p.[SupplierId] = s.[ID] 

enter image description here

+0

它可能是BRANDMASTER或SUPPLIERAMSTER拼寫錯誤後的空格。 –

+0

我再次檢查,直到現在沒有發現拼寫錯誤@AndyG –

回答

1

當您連接兩個以上的表,需要括號:

FROM (([PRODUCTMASTER] p LEFT JOIN [CATEGORYMASTER] c on p.[CategoryId] = c.[ID]) 
LEFT JOIN [BRANDMASTER ] b on p.[BrandId] = b.[ID]) 
LEFT JOIN [SUPPLIERAMSTER] s on p.[SupplierId] = s.[ID] 

我會建議使用查詢builer建立SQL查詢,它比手動更容易,你贏了」沒有這樣的拼寫錯誤和包圍錯誤。在[BRANDMASTER ]之後再檢查一次空間,這在任何情況下都是不好的做法。刪除表格定義中列名稱的尾部空格,可能會導致其他奇怪的錯誤。

+0

空間被刪除,但仍然收到錯誤。我不明白爲什麼。 –

+0

好吧,我會嘗試使用查詢生成器。謝謝 –

相關問題