mysql update sql

select userno,sum(small_posttaxprize) t1  from lottery_order  where order_result_status in  (3,4) group by userno ;

select userno, sum(commisionPrizeAmt+prizeAmt) t2 from lottery_caselot_buy group by userno;

 

select userno,sum(small_posttaxprize) total  from lottery_order  where order_result_status in  (3,4) group by userno;

update user_account a  inner join (select userno,sum(small_posttaxprize) total  from lottery_order  where order_result_status in  (3,4) group by userno) c set total_prize_amt=c.total wherhere a.userno=c.userno;
update user_account a inner join(select * from(select userno, sum(commisionPrizeAmt+prizeAmt) total   from lottery_caselot_buy group by userno having total>0) t)tt  set total_prize_amt=total_prize_amt+tt.total where a.userno=tt.userno;

你可能感兴趣的:(update)