MS ACCESS 中的嵌套内部连接与外部连接

Nested Inner Join With Outer Join in MS ACCESS

我已经查看了之前关于此主题的一些问题,但似乎无法找到我的问题的答案。

我有 3 个表(批次、菜单、SKU)。

对于给定的 SKU,我需要菜单中的所有成分及其在 SKU 中的关联产品名称,即使 LOT 中没有关联的行也是如此

我当前的查询:

    select m.IngrSKU, m.IngMeasurementID, s.productName, m.quantity as   mQuantity, l.quantity, l.lot 
    from (Menu m 
    inner join sku s on m.ingrsku = s.sku)
    left outer join lot l on m.ingrsku + '-070516j' = l.lot and l.destinationid = 2 
    where m.skutype = 4 and m.SKU = '1321'

我读到外连接必须在内连接之后进行,但我仍然遇到 "Join Expression Not Supported" 错误。

有什么想法吗?

更新:此查询在 SQL 服务器中提供了所需的结果集;只是无法在 Access

中将其设置为 运行

你试过没有括号吗?

select m.IngrSKU, m.IngMeasurementID, s.productName, m.quantity as , mQuantity, l.quantity, l.lot 
from Menu m 
join sku s on m.ingrsku = s.sku
left join lot l on m.ingrsku + '-070516j' = l.lot and l.destinationid = 2 
where m.skutype = 4 and m.SKU = '1321'
    select y.IngrSKU, y.IngMeasurementID, y.productName, 
y.quantity as   mQuantity, y.quantity, y.lot  
    from  ((select *
        from Menu m 
        inner join sku s on m.ingrsku = s.sku ) x
        left outer join lot l on x.ingrsku + '-070516j' = l.lot 

and l.destinationid = 2 ) y
        where y.skutype = 4 and y.SKU = '1321'

原来问题出在左连接中的多个条件上。

我加了parens就解决了

    select m.IngrSKU, m.IngMeasurementID, s.productName, m.quantity as   mQuantity, l.quantity, l.lot 
    from (Menu m 
    inner join sku s on m.ingrsku = s.sku)
    left outer join lot l on (m.ingrsku + '-070516j' = l.lot and l.destinationid = 2) 
    where m.skutype = 4 and m.SKU = '1321'