Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Four Table Join using same table twice.
Message
De
04/06/2002 13:15:23
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
04/06/2002 12:36:41
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00664572
Message ID:
00664599
Vues:
29
This message has been marked as the solution to the initial question of the thread.
>I'm trying to build an updateable, parameterized, local view from three source tables, where one of the tables is used twice, and my (limited) SQL experience isn't enough. I've made several attempts that were wrong, including FORCE, so it's time to ask for help.
>
>LEADS iLeadPrimaryKey, iSourceKey, iNoteKey
>SOURCE iSourcePrimaryKey, iNoteKey
>NOTES iNotePrimaryKey
>
>LEADS should join SOURCE on Leads.iSourceKey=Source.iSourcePrimaryKey
>LEADS should join NOTES on Leads.iNoteKey = Notes.iNotePrimaryKey
>^ This works fine.
>NOTES should join SOURCE on Source.iNoteKey = Notes.iNotePrimaryKey
>^ Adding this gives either an empty result set, or with Notes being duplicate values, depending. It should give a different set of Notes.

If you're using the same twice as if it was two tables, you should give this second instance of the table a different alias. If I understood well,

select * from leads ;
{left/full/right} join leads on Leads.iSourceKey=Source.iSourcePrimaryKey;
... join NOTES on Leads.iNoteKey = Notes.iNotePrimaryKey ;
... join source s2 on S2.iNoteKey = Notes.iNotePrimaryKey

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform