MYSQL使用触发器来更新刚刚添加的行

时间:2019-01-11 10:13:10

标签: mysql triggers

我正在尝试在MYSQL中创建一个触发器,该触发器将更新刚插入的行中的一列。这应该计算同一表中的某些行,并将此计数添加到列中。

CREATE TRIGGER categoryOrder 
AFTER INSERT ON testTable FOR EACH ROW 
DECLARE updatecount INT;
set updatecount = ( select count(*) from testTable where siteId = new.siteId );
then
  update testTable set orderNo = updatecount where categoryId = new.categoryId;
end

我遇到以下错误“未知系统变量'updatecount'

我在做什么错了?

0 个答案:

没有答案