我正在尝试更新值为1的列,其中以下条件匹配。
UPDATE
(SELECT TBL.KEY, TBL.IS_DUPLICATE FROM MYTABLE AS TBL JOIN
(SELECT TBL1.KEY FROM MYTABLE AS TBL1 GROUP BY TBL1.KEY HAVING COUNT(TBL1.KEY)>1) SELECTION
ON SELECTION.KEY = TBL.KEY ORDER BY TBL.KEY ASC) OuterSelection
SET OuterSelection.IS_DUPLICATE = 1;
以下是运行此查询时出现的错误。
SQL错误[42807]:INSERT,DELETE,UPDATE,MERGE或TRUNCATE语句中的目标全查询,视图,类型表,具体化查询表,范围集群表或登台表是不允许请求的操作.. SQLCODE = -150,SQLSTATE = 42807,DRIVER = 4.16.53
答案 0 :(得分:1)
问题是必须在WHERE子句中匹配选择,UPDATE应该只指定表。这是解决方案:
UPDATE TBL
SET IS_DUPLICATE=1
WHERE KEY IN (SELECT KEY
FROM TBL
GROUP BY KEY
HAVING COUNT(*) > 1);