select category_id, parent_id from categories where tree_id = :tree_id order by left_ind update categories set left_ind = -left_ind, right_ind = -right_ind where tree_id = :tree_id update categories set left_ind = :left_ind, right_ind = :right_ind where category_id = :category_id insert into category_temp values (:category_id)