Think of the model of nested sets as a file XMLwith lftand rgt, which are the strings in which the current and end tags are located:
1 <root>
2 <item1>
3 </item1>
4 </root>
To insert a new subtag in root, you will need to shift all subsequent entries:
1 <root>
2 <item1>
3 </item1>
4 <item2>
5 </item2>
6 </root>
, item2.lft item2.rgt ( item2.rgt + 1 item1.rgt + 2), lft rgt all, , item1.rgt:
UPDATE mytable
SET rgt = rgt + 2
WHERE rgt > item1.rgt
UPDATE mytable
SET lft = lft + 2
WHERE lft > item1.rgt