I have a table. Let say it has 2 columns . Column 1 is Id , column 2 is dependent ID If I want to know , all Ids that are dependent upon an ID. This dependency can be transitive .
i.e if Id1 is dependent upon Id2 and Id3 is dependent upon Id1. then If I want all dependents upon ID2 tesult should then the both Id2 and Id1.
For this I will have to fire multiple queries to mysql until I get a nullSet.
I.e
Select Id where dependentID='ID2';
This will give one set. Then I will have to recursively fire the above query on the ID set which is outputted by the above query. Can I do it in just one query somehow i.e only one I/O or is there a better way then the above approach ?
The database I am using is MYSQL.