0
我有一个简单的问题。嵌套集模型分层数据
我的数据库结构为:
id | name | left | right // no need to tell me that left, right are reserved keywords
在数据库中的唯一的数据:
1 | family | 1 | 2
现在,我想新child
添加到家庭:mother
。所以从理论上讲,我应该把我想要添加孩子的元素的正确价值和释放后的空间释放出来。
UPDATE `hp_tree` SET `right`=`right`+2 WHERE `right` > 2;
UPDATE `hp_tree` SET `left`=`left`+2 WHERE `left` > 2;
,然后只需插入子mother
:
INSERT INTO `hp_tree` SET `left`=2, `right`=3, `name`='Mother';
现在的问题是,这样的family
(根元素)right
值不被更新。我做错了吗?