2
UPDATE Recipes RE, (
    SELECT SUM((((i.iCaseCost/i.iCaseQty)/i.iUnitSize)/i.iUnitSoldBy)*ri.riQty*ri.riMeasureBy) AS     'RecipeCost'
      FROM Recipes r INNER JOIN RecipeIngredients ri
        ON r.rID = ri.rID JOIN Ingredients i
        ON ri.iID = i.iID 
        WHERE ri.rID = RE.rID
    ) t
    SET RE.rYieldCost = t.RecipeCost

执行时,我收到以下错误:“'where 子句'中的未知列'RE.rID'”。

有任何想法吗?

4

1 回答 1

1

您的内部派生查询对外部查询中的列一无所知。尝试将 WHERE 移动到 UPDATE 子句中,例如WHERE t.rID = RE.rID.

于 2012-04-26T19:05:23.617 回答