如何使用内部联接

时间:2017-02-09 11:11:44

标签: sql-server ms-access ms-access-2013 ms-access-2003

我有这个查询

Update ProductionDetails P Inner join 
(   SELECT Distinct A.BaseCode, A.BaseScale, (A.BaseScale * B.BasePer / 100)  AS BaseVal,  A.TreadCode, A.TreadScale, (A.TreadScale * B.TreadPer / 100) as TreadVal,  A.InterfaceCode, A.LipCode, A.LipScale,
    (A.LipScale * B.HsPer / 100) as LipVal, A.CenterCode, A.CenterScale, (A.CenterScale * B.CenterPer / 100) AS CenterVal,  A.StencilNo 
                  from productionDetails A  inner join 
                           BlendMaster B on (A.InterfaceCode = b.Category AND A.BaseCode = B.Base AND A.TreadCode = B.Tread AND A.centerCode = B.center)  
          Where B.Status = yes
) AS ResTable on ( P.StencilNo = ResTable.StencilNo ) 
        Set P.BaseValue = ResTable.BaseVal, P.TreadValue = ResTable.TreadVal , P.LipValue = ResTable.LipVal, P.CenterValue = ResTable.CenterVal

我需要使用 中的计算值更新 BaseValue,TreadValue,CenterValue,LipValue 字段中的 ProductionDetails 表(SELECT Query ...) AS ResTable

如果我写命令从ResTable中选择我得到了值,但如果我更新它就说错误"操作必须使用可更新的查询"。我需要在 MS Access 2013

上运行此功能

以下是样本数据的查询

CREATE TABLE ProductionDetails(StencilNo Text, LipCode Text, LipScale Text,LipValue Number,BaseCode Text,BaseScale Number,BaseValue Number,InterfaceCode Text,CenterCode Text,CenterScale Number,CenterValue Number,TreadCode Text,TreadScale Number,TreadValue Number)

Create Table BlendMaster (Category Text, Base Text, BasePer number , HsPer number, Center text,  CenterPer number,  Tread text, TreadPer number)

Insert into ProductionDetails (StencilNo, LipCode , LipScale  ,BaseCode ,BaseScale , InterfaceCode ,CenterCode , CenterScale , TreadCode ,TreadScale  ) 
VALUES ('C160405234', '-', 0,'BFA10',48.44,'BF10+CEG28' , 'CEG28', 36.5, 'TRR51', 52.56)

Insert into BlendMaster (Category, Base, BasePer ,HsPer, Center , CenterPer , Tread,TreadPer  ) 
VALUES ('BF10+CEG28', 'BFA10',25, 25, 'CEG28', 15, 'TRR51', 18)

1 个答案:

答案 0 :(得分:2)

我认为应该像这样进行更新

promise()
.then()
.error() OR
.catch()