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)

  • 相关阅读:
    CodeSmith中SchemaExplorer属性的介绍
    Bugku-INSERT INTO 注入
    XCTF-PHP2
    网络安全实验室CTF-注入关
    XSS挑战
    SQL注入
    CTFHub-技能树-命令执行
    CTFHub-技能树-文件上传
    史上最难的一道Java面试题 (分析篇)
    高可用的一些思考和理解
  • 原文地址:https://www.cnblogs.com/wxc1/p/7654996.html
Copyright © 2011-2022 走看看