Ok so what I'm trying to do is for form there is an option to set a Parent Organization for the current Organization. But I have to remove descendants of any level (could be an immediate child, or a 28th generation child etc) from the list and I'm not sure if I can do it in one query or not. The table structure (simplified) is: Organizations: id int PK, name, ParentID (points to PK, nullable) Obviously its easy to remove immediate children (WHERE ParentID <> $currentID) but how to also ignore each child's children, and their children, and.... you get the idea.
Any thoughts? Do you need more info or is there a sample I've not been able to find googling?