My issue is this. I am accessing a badly designed old equipment inventory system and what it has is multiple levels of equipment in a single table.
For Example:
Table: Equipment
|EQ_1 | EQ_2|
|123 | |
|123 | 456 |
|123 | 567 |
|456 | 789 |
|567 | |
|789 | 987 |
As you can see first piece of equipment has one entry for itself 123, and two further entries for pieces of equipment attached to it 456 and 567. From here 567 is only itself but 456 is attached to 789 and that is further attached to 987.
I have joined the table back onto itself a few times but I keep running into equipment with deeper connections than I compensate for. What I would like to find is a way to get the "endpoints" no matter how deep they are.
Example:
I input 123 as the piece of equipment I want to see all equipment on and I get a return of
123
456
567
789
987
I am doing this query through PHP code so if there are suggestions using that I am open to it but since there are hundreds of thousands of connections I would like to prevent passing the information back and forth from the Oracle servers to the Web server and making multiple queries. Pure SQL would be first choice, PHP/SQL mix second unless you can show it is more efficient.
eq_1oreq_2? Given the result you want, it's not obvious to me that you need to work through the linkages at all.