以下是我的查询
SELECT * FROM ELP_CERT, ELP_CERT_PAYMENT WHERE ELP_CERT.CERT_NUMBER='00190005622'and
ELP_CERT.CERT_ID = ELP_CERT_PAYMENT.CERT_ID
这是针对select的,并且有一个名称为DATE_PAID_FOR
的常用字段。那么,基于以上条件,我如何更新oracle数据库中的ELP_CERT_PAYMENT.date_PAID_FOR
。
答案 0 :(得分:0)
您可以这样做:
update (
select *
from elp_cert, elp_cert_payment
where elp_cert.cert_number='00190005622'
and elp_cert.cert_id = elp_cert_payment.cert_id
)
set date_paid_for = ...
如果elp_cert_payment
引用elp_cert
中有外键,则可以使用。
答案 1 :(得分:0)
也许有一个更简单的解决方案,但这个更新应该有效
update ELP_CERT_PAYMENT ecp set date_PAID_FOR = (
select ec.date_PAID_FOR from ELP_CERT ec where ec.cert_id = ecp.cert_id
) where date_PAID_FOR in (
select ec.date_PAID_FOR from ELP_CERT ec where ec.cert_id = ecp.cert_id
and ec.CERT_NUMBER='00190005622'
);
答案 2 :(得分:0)
合并到ELP_CERT_PAYMENT A 使用ELP_CERT B. ON(A.CERT_ID = B.CERT_ID) 当匹配时 UPDATE SET A.date_PAID_FOR = B.date_PAID_FOR 哪里 A.CERT_NUMBER =' 00190005622&#39 ;;
在这里,我们正在更新ELP_CERT_PAYMENT表 使用ELP_CERT表。