这是我的TABLE DESC:
Customer (Custid, Custname, Addr, phno,panno)
Loan (Loanid, Amount, Interest, Custid)
Account (Accid, Accbal, Custid)
现在我需要为指定的条件
更新表“loan”QUERY IS:
Update the interest with 1% when Accbal >50% of Loan Amount
我几乎不需要单线查询(SQL PLUS)。是否可以对此更新进行单行查询,还是应该创建更新过程。单行查询是最受欢迎的。
答案 0 :(得分:2)
这样做
update Loan
Set Interest = Interest + (1 * Interest )/100
where Custid IN (select Custid from Account where Accbal > 50);
修改强>
update Loan
Set Interest = Interest + (1 * Interest )/100
where Custid IN (
select a.Custid
from Account left outer join Loan
on Account.Custid = Loan.Custid
where Account.Accbal > (Loan.amount)/ 2
);