Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select -SQL
Message
De
18/07/2003 10:59:40
 
 
À
18/07/2003 10:45:43
Cindy Winegarden
Duke University Medical Center
Durham, Caroline du Nord, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Titre:
Divers
Thread ID:
00811410
Message ID:
00811502
Vues:
14
>>>Hi, can anyone help me with an SQL query.
>>>
>>>My records looks like this:
>>
>>>CGR_IN  CGR_OUT DEST ORIGIN TC ANO BNO CODE
>>>noco120         UK   T1-SO3 10 123 456 AB02
>>>        noco165 UK   T1-SO3 20 123 456 AB02
>>
>>>I need an SQL query that combines informations from both records with CODE as the keyfield.
>>>
>>>How do I do this ????????
>>
>>Benn--
>>
>>A self join should do the trick. A typical example of this is an employee database and one queries to find someone's boss. Note that the same table is used with 2 aliases, A and B.
>>
>>
>>SELECT A.CGR_IN, B.CRG_Out ;
>>   FROM MyTable A, MyTable B ;
>>   WHERE A.Code = B.Code
>>
>
>The problem comes when the first record is joined to itself and to the second record (and any other records that match the Code value).

Yes, early morning response. Need to exclude the record from itself on an ID value.
AND a.ID <> b.ID
The data does raise the question of data design.

Jay
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform