本帖最后由 u011669689 于 2013-09-25 18:25:00 编辑
基础条件:
update user_money
set user_money.mOney=
(select sum(ume.money) as m , u.userid from user_money_exchange ume left join user u on ume.username = u.username where ume.ordertag = 1 group by ume.username
+
select sum(ume.money) as m , u.userid from user_money_exchange ume left join user u on ume.username = u.username where ume.ordertag = 2 group by ume.username)
where user_money.u_id = u.userid
sql select update
分享到:
update user_money um left join user u on um.u_id=u.userid
left join
(select username,sum(money) as moneys from user_money_exchange group by username) ume
on ume.username=u.username
set um.mOney= ume.moneys