0
UPDATE UMSD_FILE_SNAPSHOT FS
         SET (data_msisdn, data_timestamp) = (SELECT msisdn, sacct_estab_dt
                                                FROM UMSD_FILE_SNAPSHOT_1D
                                               WHERE cust_acct_no =
                                                     FS.cust_acct_no
                                                 AND cust_sacct_no = '1D'
                                                 AND ROWNUM < 2),
             (fax_msisdn, fax_timestamp) = (SELECT msisdn, sacct_estab_dt
                                              FROM UMSD_FILE_SNAPSHOT_1D
                                             WHERE cust_acct_no =
                                                   FS.cust_acct_no
                                               AND cust_sacct_no = '1F'
                                               AND ROWNUM < 2),
             (video_msisdn, video_timestamp) = (SELECT msisdn, sacct_estab_dt
                                                  FROM UMSD_FILE_SNAPSHOT_1D
                                                 WHERE cust_acct_no =
                                                       FS.cust_acct_no
                                                   AND cust_sacct_no = '1V'
                                                   AND ROWNUM < 2)
       WHERE NVL(twc_status, ' ') <> 'S'
       AND cust_sacct_no = '1';
4

1 回答 1

0

Mysql 和 MsSQL 支持在更新语句中加入,但 oracle 没有这样使用以下查询

MERGE
INTO    table1
USING   (
        SELECT  t1.rowid AS rid, t2.code
        FROM    table1 t1
        JOIN    table2 t2
        ON      table1.value = table2.DESC
        WHERE   table1.UPDATETYPE='blah'
        )
ON      (rowid = rid)
WHEN MATCHED THEN
UPDATE
SET     value = code;

PS 请在实施前检查执行计划和成本。

于 2013-04-09T13:41:16.300 回答