Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL inner join query challenge
Message
 
 
To
10/11/2009 11:33:49
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01434050
Message ID:
01434065
Views:
36
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform