mysql group sum query and update to another table

update fa_user u inner join (select sum(num) as total_withdraw_2,user_id from `fa_withdrawal_log` as l  where  l.status=1 group by l.user_id) as ll on ll.user_id=u.id set u.total_withdraw = ll.total_withdraw_2

I searched a few online but couldn't solve my problem. This one is better.

Guess you like

Origin blog.csdn.net/sinat_25884075/article/details/130257011