oracle 多表联合更新

需要用到exists

 

UPDATE TBL_REALTIME_AD_USER_RPT T3
       SET T3.AD_PRICE = (SELECT PRICE
                            FROM TBL_ROTATE_AD T4
                           WHERE T3.AD_ID = T4.ID
                             AND TO_CHAR(T4.CREATE_DATE, 'YYYYMMDD') =
                                 V_REPORT_DATE)
     WHERE EXISTS
     (SELECT 1
              FROM TBL_ROTATE_AD T4
             WHERE T3.AD_ID = T4.ID
               AND TO_CHAR(T4.CREATE_DATE, 'YYYYMMDD') = V_REPORT_DATE)
       AND T3.REPORT_DATE = V_REPORT_DATE;

你可能感兴趣的:(oracle)