我有以下问题
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 JOIN
将FUNDING_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
语句在所有行上执行,而不是只在子查询返回的第一行上执行。
1条答案
按热度按时间sqxo8psd1#
这是因为只有PROPOSAL_NUMBER 4214存在于PROP_ADMIN表中。所有剩余的338个PROPOSAL_NUMBER将来自EPS_PROPOSAL表。请注意,您正在执行一个完全外部连接来拉取这339条记录。因此,很明显,只有非常少的记录被更新。希望它能有所帮助!