且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

与某些表连接时,更新查询出现语法错误

更新时间:2023-02-04 07:51:11

Oracle不支持update语法中的join:

Oracle does not support join in the update syntax:

UPDATE T123
    SET COL1 = 1,
        VER1 = VER1 + 1
    WHERE EXISTS (SELECT 1 FROM WAPTDT_123 T WHERE T123.REQUEST_ID = T.NUM_FLD);

这是标准的SQL,可以在任何数据库中使用.

This is standard SQL and should work in any database.

您的查询还有其他问题. . .子查询不在括号中,inner join没有第一张表.

Your query has other problems as well . . . the subquery is not in parentheses, the inner join has no first table.

您可以使用该子查询编写此查询:

You can write this query with that subquery:

UPDATE T123
    SET COL1 = 1,
        VER1 = VER1 + 1
    WHERE T123.REQUEST_ID IN (SELECT C1 FROM ( SELECT T.NUM_FLD C1 FROM WAPTDT_123 T) TAB );

我将其切换为IN,只是因为这是另一种选择.您仍然可以使用EXISTS.

I switched this to an IN, just because that is another option. You could still use EXISTS.