码迷,mamicode.com
首页 > 数据库 > 详细

mysql update select 从查询结果中更新数据

时间:2019-06-13 20:30:12      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:user   更新   from   ota   mon   select   数据   pre   mes   

UPDATE user_online_month_atu a
INNER JOIN (
SELECT
user_id,
sum(c.online_times) as totalSum,
LEFT(c.log_date,length(c.log_date) - 2) as date
FROM
user_online_time_atu c
GROUP BY
c.user_id ,date
) b ON a.user_id = b.user_id AND a.`month`=b.date
SET a.online_time = b.totalSum

  

mysql update select 从查询结果中更新数据

标签:user   更新   from   ota   mon   select   数据   pre   mes   

原文地址:https://www.cnblogs.com/deepalley/p/11018918.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!