mysql中使用update select
UPDATE t_user INNER JOIN t_shake ON t_shake.user_id = t_user.user_id SET t_user.shake_total_num = t_shake.shake_total_num; UPDATE t_user INNER JOIN ( select user_id,count(id) as share_total_num from `t_share_history` group by user_id ) tmp ON tmp.user_id = t_user.user_id SET t_user.share_total_num = tmp.share_total_num; UPDATE t_user INNER JOIN ( select user_id,sum(like_num) as like_total_num from `t_user_like` group by user_id ) tmp ON tmp.user_id = t_user.user_id SET t_user.like_total_num = tmp.like_total_num;