Mysql 为什么';我的扳机坏了吗?
我的触发器:Mysql 为什么';我的扳机坏了吗?,mysql,triggers,Mysql,Triggers,我的触发器: create trigger cnt after insert on tc_contract for each rowbegin 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_
create trigger cnt after insert on tc_contract
for each rowbegin
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
在tc\U合同上插入后创建触发器cnt
每行开始
按account\u id从tc\u合同组中选择count(*)进入@num,其中account\u id=new.account\u id;
如果@num>0和@num您需要将WHERE
子句放在groupby
子句之前
i、 e
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
select count(*)
into @num
from tc_contract
where account_id = new.account_id
group by account_id;