的update
声明没有一个from
条款,如您指定。
您是否想要做这样的事情: 对于至少有2个订单超过250个货币的客户,将信用额度增加25%。
update Customers
set CreditLimit = CreditLimit * 1.25
where (select count(*)
from Orders
where Amount > 250
and orders.customer_id = Customers.customer_id)) >= 2;
编辑
我刚才注意到您使用的是Oracle(ORA的消息)。由于您有可能更新所有客户,我相信最高性能的方式是使用“可更新连接”或下面的合并语句:
merge
into customers
using (select customer_id
from Orders o
where amount > 250
group
by customer_id
having count(*) >= 2
) orders
on(customers.customer_id = orders.customer_id)
when matched then
update
set customers.creditlimit = customers.creditlimit * 1.25;