我的FROM语句中有3个内部联接和一个左联接

时间:2019-06-27 00:35:28

标签: sql ms-access

我正在调试带有SQL后端的MS Access程序的一些代码。查询之一是产生以下错误:“作为事件属性设置输入的单击时的表达式产生了以下错误:

  

无法在备忘录,OLE或超链接对象(master_export.item = vw_items.Item)上加入”

这是原始代码:

SELECT master_export_pt.commitment_number AS [Commitment Number], 
  Sum(master_export_pt.receipt_amount) AS Amount, 
  LocalLocation.Location_Name AS Child_Location_Name, 
  LocalLocation_1.Location_Name AS Parent_Location_Name, 
  BypassLocation.JNL_Sales AS ByPassSales, 
  BypassLocation.JNL_COGS AS ByPassCogs, 
  master_export_pt.order_type
FROM (((master_export_pt 
  INNER JOIN vw_items ON master_export_pt.item = vw_items.Item) 
  INNER JOIN BypassLocation ON master_export_pt.location_id = BypassLocation.location_id) 
  INNER JOIN LocalLocation ON BypassLocation.location_id = LocalLocation.Location_ID) 
  LEFT JOIN LocalLocation AS LocalLocation_1 
    ON LocalLocation.parent_location_id = LocalLocation_1.Location_ID

并尝试将第一个JOIN更改为:

FROM (((master_export_pt, vw_items) 
  where (master_export_pt.item = vw_items.Item)) 
  INNER JOIN BypassLocation ON master_export_pt.location_id = BypassLocation.location_id) 
  INNER JOIN LocalLocation ON BypassLocation.location_id = LocalLocation.Location_ID) 
  LEFT JOIN LocalLocation AS LocalLocation_1 
    ON LocalLocation.parent_location_id = LocalLocation_1.Location_ID

但是现在我收到“ JOIN操作中的语法错误”错误消息。有没有一种方法可以不使用嵌套的JOIN语句来重新编写查询?

1 个答案:

答案 0 :(得分:0)

感谢所有答复。我尝试了以下代码,并且似乎已经完成了窍门:

I