Re: Select across link tables - A Question
Date: 27 Jan 1994 18:04:39 GMT
Message-ID: <2i8vno$mq3_at_usenet.INS.CWRU.Edu>
In a previous article, jniman_at_ernsty.co.uk (Jonathan Niman) says:
>An unusual (?) requirement for SQL ?
>Consider:
>Tables T1, T2 and T3.
>T1 contains employees like 'George'.
>T2 contains zero, one or many activities that employees (e.g. 'George')
>undertake, such as 'SQL Programming' and 'Posting Questions about SQL'.
>T3 contains zero, one or many hobbies that employees (e.g. 'George', again)
>absolutely love, such as 'Chess' and 'Crosswords'.
>Therefore, we have: T2>--T1--<T3 (I've missed off the outer join for clarity).
>I know we can 'select T1.employee,
> T2.activity,
> T3.hobby
> from T1,T2,T3
> where T1.employee=T2.employee(+) and
> T1.employee=T3.employee(+);
>But I want to prevent 'SQL Programming' and 'Chess', for example, appearing
>more than once in the result.
>I hope this is clear (and not a FAQ)!
>Thanks.
>
>
>+---------------------------------------------------------------------------+
>| Jonathan Niman | Email - jniman_at_ernsty.co.uk |
>| Database Administrator | |
>| Ernst & Young | Direct line - +44 071 931 1539 |
>| NISD, Systems Development | Switch Board - +44 071 928 2000 |
>| Rolls House, 7 Rolls Buildings, | |
>| Fetter Lane, London EC4A 1NH | Fax - +44 071 931 6500 |
>+---------------------------------------------------------------------------+
>
How about select distinct...? That should get rid of any duplicates.
-- Diana Tracy, System Designer -- Excitement, Adventure bs794_at_cleveland.Freenet.Edu -- and Really Wild ThingsReceived on Thu Jan 27 1994 - 19:04:39 CET