0

我正在尝试从 DB2 数据库中的 CLOB 字段中删除最后 10 个字符。我可以这样做:

UPDATE  report
SET     comment = LEFT(comment, (LENGTH(comment) - 10))

但是,我想根据报告是否在当前报告期间将截断限制为行的子集。我试过这个...

UPDATE  report
SET     comment =
        (   SELECT  LEFT(comment, (LENGTH(comment) - 10))
            FROM    report

                    INNER JOIN report_period
                    ON report.report_period_id = report_period.report_period_id

            WHERE   report_period.name = '2013 Interim Report'  )

...但我明白了

The result of a scalar fullselect, SELECT INTO statement, or
VALUES INTO statement is more than one row

我究竟做错了什么?

4

1 回答 1

0

没关系...问这个问题有助于在我的脑海中清除它。只需将连接移至 WHERE 子句....

UPDATE  report
SET     comment = LEFT(comment, (LENGTH(comment) - 10))
WHERE   report_id IN
        (   SELECT  report_id 
            FROM    report

                    INNER JOIN report_period
                    ON report.report_period_id = report_period.report_period_id

            WHERE   report_period.name = '2013 Interim Report'  )
于 2013-04-05T00:37:24.013 回答