我在MS Access中编写了一个查询,当我尝试运行此查询时出现错误。我无法找到问题所在。
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]
答案 0 :(得分: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]
我建议使用查询编译器构建SQL查询,它比手动更容易,你不会像这样拼错错误和包围错误。再次检查[BRANDMASTER ]
之后的空格,这在任何情况下都是不好的做法。从表定义中的列名中删除尾随空格,可能会导致其他奇怪的错误。