简体   繁体   English

MS Access UPDATE 查询错误

[英]MS Access UPDATE Query errors

I am having a hard time using MS Access because the syntax is a little finicky compared to other db's.我很难使用 MS Access,因为与其他数据库相比,语法有点挑剔。

I am trying to validate a table and compare that table to a master table with multiple columns of information.我正在尝试验证表并将该表与具有多列信息的主表进行比较。 At the moment I am trying to update a table with a field name of Difference_Value in table ct2011 to be equal to (ct2011.Distribution_Amount - AggregateFinal.SumOfDollars) .目前,我正在尝试将表ct2011具有Difference_Value字段名称的表ct2011为等于(ct2011.Distribution_Amount - AggregateFinal.SumOfDollars)

Also specifying the lines in which are going to be updated because not all rows in the MASTER are in the table ct2011 .还要指定要更新的行,因为并非 MASTER 中的所有行都在表ct2011

Below is my query.以下是我的查询。

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;

I am getting a Syntax error (missing operator) .我收到Syntax error (missing operator) It specifies that it is encountering the error during the SET expressions after the = .它指定它在=之后的SET expressions期间遇到错误。

In an MS Access update query, the join criteria should follow the update keyword, eg:在 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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM