CREATE TRIGGER tttttt AFTER INSERT ON xxx
FOR EACH ROW BEGIN
UPDATE Category SET Path =
CONCAT(IF(NEW.ParentID IS NULL,'.' ,ParentCategory.Path),CAST(NEW.Id AS char(10)) , '.')
FROM Category ON Inserted.Id = Category.Id
LEFT JOIN Category AS ParentCategory ON Category.ParentCategoryId = ParentCategory.Id
WHERE Category.Id = NEW.Id
END;
|