如何使用连接更新多个表列

时间:2013-11-12 11:56:38

标签: mysql sql-server sql-update

我希望像单个查询一样更新多个表...比如

update astatus a1,provider pr1,location br1 JOIN(
select br.id as bId,pr.id as pId,a.id as aId 
from astatus a,member m,provider pr,pricing_plan p,location br,pricing_scheme ps 
where date(a.next_payment_date)<=date(subdate(current_date, 1)) 
and   a.pricing_plan_id=p.id 
and p.pricing_scheme_id=ps.id 
and ps.type='SUBSCRIPTION' 
and a.status is null 
and m.astatus_id is not null 
and m.astatus_id=a.id 
and pr.member_id=m.id 
and br.provider_id=pr.id ) 
as dup 
ON a1.id=dup.aId,pr1.id=dup.pId,br.id=dup.bId
set a1.pricing_plan_id=null,pr1.auto_applied=0,br1.featured=0

但是它给出了错误..请帮帮我

1 个答案:

答案 0 :(得分:2)

更改此

 ON a1.id=dup.aId,pr1.id=dup.pId,br.id=dup.bId

 ON a1.id=dup.aId and pr1.id=dup.pId and br.id=dup.bId