前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >update issue a join TABLE b on on a.id=b.isid set a.group_date= b.groupDateupdate issue a join TABLE

update issue a join TABLE b on on a.id=b.isid set a.group_date= b.groupDateupdate issue a join TABLE

作者头像
一个会写诗的程序员
发布2018-08-17 14:23:13
2310
发布2018-08-17 14:23:13
举报
文章被收录于专栏:一个会写诗的程序员的博客

update issue a join TABLE b on on a.id=b.isid set a.group_date= b.groupDate

代码语言:javascript
复制
<update id="batchUpdateIssueGroupDate">
    <![CDATA[

    
    
    ]]>
</update>

update issue a join (SELECT iss.id isid, @cdate := iss.commit_date input_date, @last_sat := date_add(date_sub(date_sub(@cdate,interval day(@cdate)-1 day),interval 1 month), interval 6-date_format(date_sub(date_sub(@cdate,interval day(@cdate)-1 day),interval 1 month),'%w') day) last_sat, @this_sat := date_add(date_sub(@cdate,interval day(@cdate)-1 day), interval 6-date_format(date_sub(@cdate,interval day(@cdate)-1 day),'%w') day) this_sat, @next_sat := date_add(date_add(date_sub(@cdate,interval day(@cdate)-1 day),interval 1 month), interval 6-date_format(date_add(date_sub(@cdate,interval day(@cdate)-1 day),interval 1 month),'%w') day) next_sat, @last_point := if(day(@last_sat)-3>0,date_sub(@last_sat,interval 7 day),@last_sat) last_point, @this_point := if(day(@this_sat)-3>0,date_sub(@this_sat,interval 7 day),@this_sat) this_point, @next_point := if(day(@next_sat)-3>0,date_sub(@next_sat,interval 7 day),@next_sat) next_point , case when @cdate >= @last_point and @cdate < @this_point then concat( 'W', datediff(@cdate,@last_point) div 7 + 1, '/', year(@cdate),'-', if(month(@last_sat)>=10,month(@last_sat),concat('0',month(@last_sat))) ) when @cdate >=@this_point and @cdate < @next_point then concat( 'W', datediff(@cdate,@this_point) div 7 + 1,'/', year(@cdate),'-', if(month(@this_sat)>=10,month(@this_sat),concat('0',month(@this_sat)))) else concat( 'W', datediff(@cdate,@next_point) div 7 + 1,'/', year(@cdate),'-',if(month(@next_sat)>=10,month(@next_sat),concat('0',month(@next_sat)))) end as groupDate from issue iss) b on a.id=b.isid

set a.group_date= b.groupDate;

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2017.10.20 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • update issue a join TABLE b on on a.id=b.isid set a.group_date= b.groupDate
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档