Prestashop 1.6获取特定类别产品的特征值

时间:2014-08-17 14:00:16

标签: mysql sql prestashop-1.6

我试图获取特定类别产品的特定功能的价值。 id_category_default是13(处理器),id_feature是6(功率(W) 我要找的输出应该是这样的:

<ProcessorName><ValueOfFeature>

直到现在我才尝试过:

 SELECT pl.name,fvl.value 

from ps_product_lang pl,ps_product p,ps_feature_value_lang fvl,ps_feature_value fv,ps_feature f,ps_feature_lang fl
where pl.id_product=p.id_product
and p.id_product in (SELECT id_product
             from ps_feature_product
             where id_feature in (select id_feature
                      from ps_feature
                      where id_feature = 6))
and pl.id_lang = 1
and pl.id_shop = 1
and p.id_shop_default=1
and p.id_category_default =13
and fvl.id_feature_value=fv.id_feature_value
and fv.id_feature=f.id_feature
and fvl.id_lang=1
and fl.id_feature =f.id_feature
and fl.id_lang=1
and f.id_feature=6

输出是这样的:

  <ProcessorName1><NameOfFeature><value 1 OfFeature>
  <ProcessorName1><NameOfFeature><value 2 OfFeature>
  <ProcessorName1><NameOfFeature><value 3 OfFeature>
  <ProcessorName1><NameOfFeature><value 4 OfFeature>

  <ProcessorName2><NameOfFeature><value 1 OfFeature>
  <ProcessorName2><NameOfFeature><value 2 OfFeature>
  <ProcessorName2><NameOfFeature><value 3 OfFeature>
  <ProcessorName2><NameOfFeature><value 4 OfFeature>

  <ProcessorName3><NameOfFeature><value 1 OfFeature1>
   etc
  <ProcessorName4><NameOfFeature><value 1 OfFeature1>
   etc

我需要的是获得具有特定产品的id_feature = 6值的功能:

 <processorName1><valueOfFeature>
   <processorName2><valueOfFeature>
   <processorName3><valueOfFeature>
   <processorName4><valueOfFeature>

非常感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

解决了我必须更多地查看数据库模式并设法编写正确的sql查询