使用完全外部联接和子查询的ORACLE UPDATE

n53p2ov0  于 2023-03-07  发布在  Oracle
关注(0)|答案(1)|浏览(133)

我有以下问题

SELECT DISTINCT EPS_PROPOSAL.PROPOSAL_NUMBER FROM PROP_ADMIN, EPS_PROPOSAL
    FULL OUTER JOIN PROP_ADMIN 
    ON EPS_PROPOSAL.PROPOSAL_NUMBER = PROP_ADMIN.PROPOSAL_NUMBER
    WHERE EPS_PROPOSAL.SPONSOR_CODE = 100728 AND 
        (EPS_PROPOSAL.STATUS_CODE = 3 OR EPS_PROPOSAL.STATUS_CODE = 6)
PROPOSAL_NUMBER    FUNDING_CODE
    4214              (null)
    3079              (null)
    3212              (null)
      .                  .
      .                  .
 TOTAL RECORDS: 339

我正尝试使用以前使用的WHERE条件和OUTER JOINFUNDING_CODE更新为F

UPDATE PROP_ADMIN
    SET FUNDING_CODE = 'F'
    WHERE PROPOSAL_NUMBER IN(
       SELECT DISTINCT EPS_PROPOSAL.PROPOSAL_NUMBER FROM PROP_ADMIN, EPS_PROPOSAL
       FULL OUTER JOIN PROP_ADMIN 
       ON EPS_PROPOSAL.PROPOSAL_NUMBER = PROP_ADMIN.PROPOSAL_NUMBER
           WHERE EPS_PROPOSAL.SPONSOR_CODE = 100728 AND 
           (EPS_PROPOSAL.STATUS_CODE = 3 OR EPS_PROPOSAL.STATUS_CODE = 6)

当我运行这个命令时,上面的列表中只有1行被更新。

PROPOSAL_NUMBER     FUNDING_CODE
     4214                F
     3079              (null)
     3212              (null)
      .                  .
      .                  .

如何使UPDATE语句在所有行上执行,而不是只在子查询返回的第一行上执行。

sqxo8psd

sqxo8psd1#

这是因为只有PROPOSAL_NUMBER 4214存在于PROP_ADMIN表中。所有剩余的338个PROPOSAL_NUMBER将来自EPS_PROPOSAL表。请注意,您正在执行一个完全外部连接来拉取这339条记录。因此,很明显,只有非常少的记录被更新。希望它能有所帮助!

相关问题