场景案例:多表关联update(用户积分奖励)
场景:
根据运营需求,譬如我们 规定 在 某2天内,凡是消费的客户给予 消费金额的10%作为积分奖励,
以最大的一天为准,不累加 。
update users_score a INNER JOIN (select max(paymoney) as mp,user_name from users_buy group by user_name ) b on a.user_name=b.user_name
set a.user_score= a.user_score+(b.mp*0.1)
转载于:https://blog.51cto.com/chinaleo/1935026