公司sql

作者: HashHim | 来源:发表于2019-08-14 10:44 被阅读0次
    select * from CODETABLE where ALIAS = 'PUB_CURRENCY_EXCHRATE'    //代码中心查找语句
    select * from MODULESERVICE where SERVICENAME like 'loan%'      //
    
    
    
    update T_w5oc3z6meoewukf1iqxl35_k set LX_ZZDATE = (select DATE_ADD(DATE_FORMAT(min(b.LX_QSDATE),'%Y-%m-%d'),INTERVAL  -1 DAY) from (select * from T_w5oc3z6meoewukf1iqxl35_k) b where b.LX_QSDATE > T_w5oc3z6meoewukf1iqxl35_k.LX_QSDATE and b.DRAW_BILLID = T_w5oc3z6meoewukf1iqxl35_k.DRAW_BILLID)
    

    解决MySQL的update语句无法使用用一个表的自查询问题

    //sqlserver
    update T_7gf_y0iuudl1_h2uh9q1_gv3h set LX_ZZDATE = IFNULL((select DATE_ADD(DATE_FORMAT(min(b.LX_QSDATE),'%Y-%m-%d'),INTERVAL  -1 DAY) from T_7gf_y0iuudl1_h2uh9q1_gv3h b where b.LX_QSDATE > a.LX_QSDATE and b.DRAW_CODE = a.DRAW_CODE), null) from T_7gf_y0iuudl1_h2uh9q1_gv3h a 
    
    //mysql
    update T_w5oc3z6meoewukf1iqxl35_k set LX_ZZDATE = IFNULL((select DATE_ADD(DATE_FORMAT(min(b.LX_QSDATE),'%Y-%m-%d'),INTERVAL  -1 DAY) from (select * from T_w5oc3z6meoewukf1iqxl35_k) b where b.LX_QSDATE > T_w5oc3z6meoewukf1iqxl35_k.LX_QSDATE and b.DRAW_BILLID = T_w5oc3z6meoewukf1iqxl35_k.DRAW_BILLID),NULL);
    
    
    //sqlserver
    update T_5tnu6ohq824om1nl3uo1eezrb set LX_YE = a.LX_YE + IFNULL((select sum(LX_YE) from T_5tnu6ohq824om1nl3uo1eezrb where DRAW_BILLID = a.DRAW_BILLID and LX_QSDATE < a.LX_QSDATE), 0) from T_5tnu6ohq824om1nl3uo1eezrb a
    //mysql
    update T_5tnu6ohq824om1nl3uo1eezrb set LX_YE = T_5tnu6ohq824om1nl3uo1eezrb.LX_YE + IFNULL((select sum(b.LX_YE) from (select * from T_5tnu6ohq824om1nl3uo1eezrb) b where b.DRAW_BILLID = T_5tnu6ohq824om1nl3uo1eezrb.DRAW_BILLID and b.LX_QSDATE < T_5tnu6ohq824om1nl3uo1eezrb.LX_QSDATE), 0)
    

    相关文章

      网友评论

          本文标题:公司sql

          本文链接:https://www.haomeiwen.com/subject/cyowjctx.html