Jump to content

SQL guru help needed


InnovatecInc
 Share

Recommended Posts

Hi

 

I am trying to run a SQL query on my database to show all products and their respective features and feature values.

 

This is where I am but as I get the feature but every possible value for that feature - how do I limit it to just the ones used

by the product.

 

Sorry for my poor SQL skills.

 

Steve

 

Select pl.name, fl.name

 
From ps_product_lang pl
LEFT JOIN ps_feature_product fp
ON (pl.id_product = fp.id_product)
 
LEFT JOIN ps_feature_lang fl
ON (fp.id_feature = fl.id_feature)
 
LEFT JOIN ps_feature_value fv
ON (fl.id_feature = fv.id_feature)

 

 

 

 

Share this post


Link to post
Share on other sites

Try this. Should work. You may have to change the id_lang value for whatever language your store is:

 

select a.id_product, a.name as product_name,
           d.name as feature_name,
           c.value as feature_value
from ps_product_lang a, ps_feature_product b, ps_feature_value_lang c, ps_feature_lang d
where a.id_lang = 2
and a.id_product = b.id_product
and b.id_feature_value = c.id_feature_value
and a.id_lang = c.id_lang
and b.id_feature = d.id_feature
and a.id_lang = d.id_lang

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More