日期:2014-05-17 浏览次数:20423 次
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
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