Skip to content
Advertisement

sql – Deletion in closure table with multiple same paths

I have the following hierarchical structure:

Here is the closure table I’ve come up with:

I want to remove the link between B and D, and therefore I want to delete the link between A and D (the one of depth 2). The problem is that I don’t want to delete the link between A and D of depth 3 since I didn’t delete the link between C and D.

For the moment, here is the SQL statement to list the links I want to delete:

but this statement give me rows I don’t want to delete:

Advertisement

Answer

I think I’ve found the solution, for those who are interested:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement