BEGIN
SELECT CONCAT(IFNULL(parent_order, ''),IFNULL(self_order, '')) FROM tb_department WHERE id = new.parent_id into @parent_order;#查询出父级节点
SELECT LPAD(IFNULL(MAX(self_order)+1,1),3,'0') from tb_department WHERE parent_id =new.parent_id into @self_order;#查询出同级节点
SET new.self_order = @self_order;SET new.parent_order=@parent_order;#更新
END
mysql插入操作执行触发器
最新推荐文章于 2023-04-25 16:44:21 发布