If you want them as column data then yes, you would have to do all those joins.
Preferably, you could just rely on a regular row based join and your query is much simpler.
Code:
Select P.*, FeatureName=F1.name
from
PRODUCT P,
PRODUCT_FEATURE PF, FEATURE F
where
P.id = PF.product_id and feature_id = F.id and PF.value in ("V1", "V2")
and you'll get one row for each product/feature pairing.
If you still insist on the column based result, the only help a view could give would be a view that links the PRODUCT_FEATURE.product_id to the FEATURE.name, simplifying your query a bit. So:
Code:
create view PRODUCT_FEATURENAME
as
select product_id, featureName=F.name
from PRODUCT_FEATURE PF, Feature F
where
PF.feature_id = F.id and PF.value in ("V1", "v2" )
Then your original query gets simplified as such:
Code:
Select P.*, Feature1=PFN1.name, Feature2=PFN2.name, Feature3=PFN3.name, ... Feature=PFN24.name
from
PRODUCT P,
PRODUCT_FEATURENAME PFN1,
PRODUCT_FEATURENAME PFN2,
PRODUCT_FEATURENAME PFN3,
...
PRODUCT_FEATURENAME PFN24
where
P.id *= PFN1.product_id
and
P.id *= PFN2.product_id
and
P.id *= PFN3.product_id
...
P.id *= PFN24.product_id
Frankly, I don't even know if this query might push the limit on how many tables you can join against. The fact that the view exists is just a convenience but at execution time will still be expanded out. You might be better off selecting the results of the view into a temp table first.
If I may ask, what is your motivation for doing this at all?
(btw, please rate my posting)