zoukankan      html  css  js  c++  java
  • mysql 存储过程 随笔

    CREATE PROCEDURE `g2`( in sts int,in type int, code varchar(20),in s int)
    begin
    declare i int;
    declare a int;

    declare b int;
    declare t varchar(20) default '';
    set t=DATE_FORMAT(NOW(), '%Y-%m');
    set i = 1;
    truncate table faw_form_a;
    loop_example : loop
    if (type = 1) then

    select if(id,count(id),0) as id,if(status=s,s,s) as status into a,b
    from faw_form_operating where status =s and
    DATE_FORMAT(FROM_UNIXTIME(add_time),'%Y-%m-%d')=concat(t,'-',i) and
    userid in (select userid from table_name where dealer_code=code and userid!=0);
    insert into faw_form_a (id,m,c,s) values (null,i,a,b);
    else
    select if(id,count(id),0) as id,if(status=s,s,s) as status into a,b
    from faw_form_operating where status =s and
    DATE_FORMAT(FROM_UNIXTIME(add_time),'%m')=i and userid in (select userid from table_name where dealer_code=code and userid!=0);
    insert into faw_form_a (id,m,c,s) values (null,i,a,b);
    end if;
    set i = i + 1;
    if i > sts then
    leave loop_example;
    end if;

    end loop;
    select c,m,s from faw_form_a group by s,m;

    end;

    调用 call g2(1,2,"xxxx",1)

  • 相关阅读:
    装饰 Markdown
    小技巧
    LINUX 下挂载 exfat 格式 u 盘或移动硬盘
    Matlab 也很强大!
    imageio 载入 Buffer 格式的图片
    Docker 入门
    COCO 数据集使用说明书
    Python 基础 json 与pickle
    Python 基础 常用模块
    Python 基础 装饰器
  • 原文地址:https://www.cnblogs.com/wxc1/p/7654996.html
Copyright © 2011-2022 走看看