SQL QUESTION (ADVANCED ??)
Date: Wed, 31 Aug 1994 13:25:22 GMT
Message-ID: <1994Aug31.132522.6302_at_cti.wnc.nedlloyd.nl>
I have some problems writing a statement that selects the required information in the following situation:
I have two tables that have an n:m relationship, with an intersection table in between, as follows:
- ------- ------- | A |-------------<| B |>-------------| C |
- ------- -------
The relationships in table B could be like
A1-C1
A2-C2 A2-C3 A4-C4 A5-C4 A5-C5 A6-C5 A6-C6 A4-C6
Now, if I have a value for A, I want to select all other A's that are somehow connected to the given value for A. In case of A4, that would be A4, A5, A6.
The problem is that I don't know how many A's will be in such a 'group', so the use of subselects gives problems. An other problem is that the relations can 'loop'. In above example C6 points back to A4. A connect by clause will loop as well.
The problem can be solved in PL/SQL with some tricks, but I really need one SQL-statement that can do the trick.
Seems to me this is not such an extraordinary case so a solution must be around somewhere and might actually be simple.
Thanks in advance,
Jos.
-- ------------------------------------------------------------------------ Nedlloyd Computer Services _/ _/ _/_/_/_/ _/_/_/_/ P.O. Box 2454 _/_/ _/ _/ _/ 3000 CL Rotterdam (The Netherlands) _/ _/ _/ _/ _/_/_/_/ J. Kerssens _/ _/_/ _/ _/ _/ _/ _/_/_/_/ _/_/_/_/ -----------------------------------------------------------------------Received on Wed Aug 31 1994 - 15:25:22 CEST