有两张表
A(id),
B(aid,id,instance,quantity)
要求是A表和B表做联表查询,如果A对应的所有记录的quantity的合大于40
就标记 字段instance值为 important
初学,后面的那个子查询写不出来。。。
------解决方案--------------------
update b
set instance = 'important'
where id in (
select b.id from a, b
where a.id = b.id
group by b.id
having sum(quantity) > 40
)