Hello.
I have the following table structure:
I have to update/replace values:Code:id root_id 1 1 2 1 3 1 4 4 5 4 6 4
SET root_id = 4 WHERE root_id = 1
SET root_id = 1 WHERE root_id = 4
SET id = 4 WHERE id = 1
SET id = 1 WHERE id = 4
basically I want:
Q1:Code:id root_id 4 4 2 4 3 4 1 1 5 1 6 1
What is the best way to preform such query?
I would select all ids with matching values and call update query for each. There must be some better solution, with less than 4 queries needed.
Q2:
Concept consideration:
I'm using Doctrine ORM and it has some strange implementation of NestedSet structure. Each root node has own root_id and I want to be able to change the order of root nodes, so I decided to use existing root_id column for ORDER_BY instead of making new column for sort order.
Any concerns about this approach, if I wont be accessing elements by ids?
Thanks a lot for help.










Bookmarks