sql select update
基础条件: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。印象中不能这么写
试试
update user_money um left join user u on um.u_id=u.useridleft join (select username,sum(money) as moneys from user_money_exchange group by username) umeon ume.username=u.usernameset um.money = ume.moneys
谢谢,可行,非常感谢