Re: SQL QUESTION (ADVANCED ??)

From: Jack S. Moore <rpi_at_crl.com>
Date: 1 Sep 1994 10:35:48 -0700
Message-ID: <3453dk$ll4_at_crl.crl.com>


In article <1994Aug31.132522.6302_at_cti.wnc.nedlloyd.nl>, Jos Kerssens <jos_at_zeus.wnc.nedlloyd.nl> wrote:
>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.
>[...]
>Thanks in advance,

select distinct acol
from b b1
where acol in (select acol from b b2 where b2.ccol = b1.ccol and

        b2.acol = 'A4')
/

L. Scott Johnson
Senior Programmer
Research Planning, Inc.
(803) 256-7322 Received on Thu Sep 01 1994 - 19:35:48 CEST

Original text of this message