PHP高级工程师|全栈工程师|WX: Aben_Ring

mysql日常sql

 

 

重置表

truncate table david_account;

 

触发器

/* 商户资料更新时更新终端 */
DELIMITER |
CREATE TRIGGER
    bankChange
AFTER UPDATE
    ON david_bank
FOR EACH ROW
    BEGIN
        /*
        declare termC int;
        set termC = (select count(*) as nums from david_terminal where mer_id=new.mer_id);
        if termC<=1 then
            update david_terminal set
                main_tel = new.main_tel,
                sale_type_id = new.sale_type_id
            where mer_id=new.mer_id;
        end if;
        */
        update david_account set
            bank_name = new.name
        where bank_id=new.cut_no;

        if(new.channel_no = '016') then
            insert into rpt_charge set `month`=new.`month`,channel_no = new.channel_no,term_no=new.term_no;
        elseif(new.channel_no = '018') then
            insert into rpt_charge set channel_no = new.channel_no,term_no=new.term_no;
        end if;

    END
|
DELIMITER ;

 

posted @ 2017-10-11 11:14  懒牛拉车  阅读(145)  评论(0编辑  收藏  举报