MS Access UPDATE查询错误

时间:2019-02-05 15:18:53

标签: sql ms-access

我很难使用MS Access,因为与其他数据库相比,语法有点挑剔。

我正在尝试验证一个表并将该表与具有多列信息的主表进行比较。目前,我正在尝试将表Difference_Value中字段名称为ct2011的表更新为等于(ct2011.Distribution_Amount - AggregateFinal.SumOfDollars)

还要指定要更新的行,因为并非主表中的所有行都在表ct2011中。

下面是我的查询。

UPDATE ct2011
SET ct2011.Difference_Value = (ct2011.Distribution_Amount - AggregateFinal.SumOfDollars)
FROM
       ct2011 as ct
INNER JOIN 
       AggregateFinal af
ON
       ct.Employee_ID = af.EmpId AND ct.Legal_Name = af.LegalName AND ct.Distribution_Plan_Year = af.CalculationAwardPeriod AND ct.Award_Year = af.AwardPeriod;

我得到一个Syntax error (missing operator)。它指定在SET expressions之后的=期间遇到错误。

1 个答案:

答案 0 :(得分:1)

在MS Access update查询中,join条件应遵循update关键字,例如:

update 
    ct2011 ct inner join aggregatefinal af on
    ct.employee_id = af.empid and 
    ct.legal_name = af.legalname and 
    ct.distribution_plan_year = af.calculationawardperiod and
    ct.award_year = af.awardperiod
set 
    ct.difference_value = (ct.distribution_amount - af.sumofdollars)