Select across link tables - A Question

From: Jonathan Niman <jniman_at_ernsty.co.uk>
Date: Fri, 14 Jan 1994 22:20:37 GMT
Message-ID: <jniman.15.00115871_at_ernsty.co.uk>


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 |
+---------------------------------------------------------------------------+
Received on Fri Jan 14 1994 - 23:20:37 CET

Original text of this message