posted 18 years ago
Hello,
I will need to be querying a database schema which models an object hierarchy tree, with a single table containing every parent-child relationship in the tree. So to find the TypeA children of a specific parent you'd do something like
SELECT * FROM TypeA, relationships WHERE relationships.parentid = <parentid> AND relationships.childid = TypeA.id
That's straightforward enough, but what if you're trying to find grandchildren? Or a single query involving multiple different types (tables) of children? That would mean that multiple rows of "relationships.childid" would be used for the same row in the result set. Is there any way to do this without using either multiple seperate queries or nested queries.
Changing the table design of the schema is not an option, unfortunately, though it is possible to add new tables and views.
Thank you,
Yuriy