触发在插入或删除行时运行MySQL查询

时间:2013-03-06 17:39:03

标签: mysql triggers

我想在每次添加或删除新行时运行此查询

UPDATE brandnames updated
JOIN (select bname, count(*) as cnt 
from brandnames 
group by bname) aggregate 
ON updated.bname= aggregate.bname
set `count`= aggregate.cnt

请帮我一个触发条目。谢谢,

1 个答案:

答案 0 :(得分:0)

我会说you cannot

  

存储的函数或触发器无法修改已经存在的表   被调用的语句用于(读或写)   功能或触发器。