我正在尝试在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'
我在做什么错了?