Access SQL如何更新重复项?

时间:2017-01-06 18:24:53

标签: sql ms-access

现在我有一些Access SQL可以在我的表中找到重复项。我正在尝试编写一个单独的UPDATE命令来更新与这些重复项相关联的字段。

UPDATE T 
    SET BAD_CODES = BAD_CODES  & 'D'
    FROM work AS T 
    JOIN (SELECT DIVISION, FIPS_COUNTY_CODE, LAST, SUFFIX, FIRST, TITLE, BIRTHDATE, COUNT(*)
          FROM work                      
          GROUP BY DIVISION, FIPS_COUNTY_CODE, LAST, SUFFIX, FIRST, TITLE, BIRTHDATE
          HAVING COUNT(*) > 1
          ) AS S
      ON  T.DIVISION = S.DIVISION
      AND T.FIPS_COUNTY_CODE = S.FIPS_COUNTY_CODE
      AND T.LAST = S.LAST
      AND T.SUFFIX = S.SUFFIX
      AND T.FIRST = S.FIRST
      AND T.TITLE = S.TITLE
      AND T.BIRTHDATE = S.BIRTHDATE

我认为这接近我所需要的,但是我得到一个语法错误(缺少运算符),我似乎无法弄清楚。我的SQL出了什么问题?

1 个答案:

答案 0 :(得分:0)

正确的语法是:

(define (mySum L)
  (if (empty? L) 0
      (+ (first L) (mySum (rest L))))
  )

访问权限不允许更新聚合视图。您必须创建临时表并使用它进行更新,然后将其删除。