Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL SELECT format
Message
 
 
À
31/01/2007 10:51:20
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01190908
Message ID:
01190938
Vues:
15
>I am becoming curious about the best practices for formatting sql-select statements. Suppose you have 4 related tables, Parent, Child, Grandchild, and GreatGrandchild. Each of these has a one to many relationship with its parent. If we wanted to select a set of records as follows:
>
>1 parent
>1 child (1 of the child records that matches the parent)
>1 grandchild (1 of the grandchild records that matches the selected child record)
>all greatgrandchild (all of the greatgrandchild records that match the selected grandchild record)
>
>should the select begin with the parent or the greatgrandchild table, or doesn't it matter? IE
>
>select * from parent ;
>inner join child on ... ;
>inner join grandchild on ... ;
>inner join greatgrandchild on ... ;
>where somecondition
>
>or
>
>select * from greatgrandchild ;
>inner join grandchild on ... ;
>inner join child on ... ;
>inner join parent on ... ;
>where somecondition
>
>Is this a matter of form or is there a significant difference? Is one preferred as a best practice?
>
>Thanks for any insights.

I always start from the parent to the child and grandchild... I'm not sure if there is any justification for that, because usually VFP decides on the order to JOIN by its own.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform