I have 2 ORACLE tables. The first is a table of vendors, and the second is a relational table that contains a record of the ID of every vendor that sells to another vendor. For example:
Seller_ID Buyer_ID
1 2
2 3
3 4
3 5
6 5
5 2
6 1
4 7
8 11
9 10
8 10
Both of these ID fields are foreign keys to the PK in the Vendors table. What I need is SQL to return ALL the Buyer/Seller pairs in an entire chain along with the associated names of the Buyer and Seller pairs. If I am interested in seller #3, the results returned would not just be the 3/4, 3/5 and 2/3 pairs, it would keep going until the chain ends (or would become cyclical) --
3/4
4/7
3/5
5/2
2/3
1/2
6/1
Now, I just need the SQL that returns that information. I can easily get the records where ID 3 is in either of the buyer/seller fields along with the associated names; it's getting the rest of the chain that is the stickler. TIA!
Mark McCasland
Midlothian, TX USA