Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL inner join query challenge
Message
 
 
À
10/11/2009 11:33:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Database:
Visual FoxPro
Divers
Thread ID:
01434050
Message ID:
01434065
Vues:
37
Greg,

It still would be a self-join, e.g.
select M1.ModelID, M1.Name as ModelName, O1.Name as OptionName, P.Name as PackageName from Models M1
 inner join ModelOptions MO on M1.ModelID = MO.ModelID 
inner join Options O1 on MO.OptionID = O1.OptionID inner join Options P on MO.PackageID = P.OptionID
>Packageid refers to the option.optionid of the parent. I realize now I confused things. It's not a self join.
>
>option.optionid = modeloption.packageid for the contents of a package
>
> So a package with 3 records would look like this basically...
>
> Modelid Optionid Packageid
>
> 180 10 100
> 180 20 100
> 180 30 100
>
>option.optionid = modeloption.optionid for the parent of the package
>
> 180 100 0 (0 or null would indicate a parent record)
>
>
>The result set I want would be:
>
> Modelid Option.name Optionpackage.name
> -------------- ---------------------------------------- ---------------------------------------------
> 180 Option.name for optionid=10 Option.name for optionid=100
> 180 Option.name for optionid=20 Option.name for optionid=100
> 180 Option.name for optionid=30 Option.name for optionid=100
>
>
>Thanks a bunch for your help!!!
>
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