本帖最后由 zlg1981 于 2012-08-19 18:07:11 编辑

解决方案 »

  1.   

    delimiter //
    create trigger cnt after insert on tc_contract
    for each row
    begin
     select count(*) into @num from tc_contract group by account_id where account_id = new.account_id;if @num >0 and @num <3 then
    update tc_account set account_status = 2 where account_id = new.account_id;
    end if;
    end//
      

  2.   

    我用的是 mysql query browser 工具,用下面这段代码还是报错了呀:create trigger cnt after insert on tc_contract
    for each row
    begin
     select count(*) into @num from tc_contract group by account_id where account_id = new.account_id;
    if @num >0 and @num <3 then
    update tc_account set account_status = 2 where account_id = new.account_id;
    end if;
    end
      

  3.   

    我把整段复制进去也还是报错:
    delimiter //
    create trigger cnt after insert on tc_contract
    for each row
    begin
     select count(*) into @num from tc_contract group by account_id where account_id = new.account_id;if @num >0 and @num <3 then
    update tc_account set account_status = 2 where account_id = new.account_id;
    end if;
    end// 
      

  4.   

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where account_id = new.account_id;
    if @num >0 and @num <3 then
    update tc_accou' at line 4
      

  5.   

    select count(*) into @num from tc_contract where account_id = new.account_id group by account_id ;
      

  6.   

    trigger调试思路:
    1。sql是不是正确,
    2。trigger语法,
    update tc_account set account_status = '2' where account_id = new.account_id;if @num >0 and @num <3 then你真不如分二步写,这样有的环境解释不过的。
      

  7.   

    以下语句,调试已成功,请参考:
    create trigger portGo
    after insert on wc
    for each row
    begin
    select count(*) into @num from dataIn where port = new.name;
    if @num=0 then
    insert into dataIn values ('4',new.name);
    end if;
    end$