Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 显示所有产品及其属性、功能和所属类别的报告_Mysql_Prestashop - Fatal编程技术网

Mysql 显示所有产品及其属性、功能和所属类别的报告

Mysql 显示所有产品及其属性、功能和所属类别的报告,mysql,prestashop,Mysql,Prestashop,我试图建立一个报告,其中显示所有产品及其属性,功能和它所属的类别。但我写的查询需要很多时间。我如何改进这一点 [CODE] SELECT max(if((ps_attribute_group_lang.name like "Color"),ps_attribute_lang.name,'')) AS Color, max(if((ps_attribute_group_lang.name like "Size"),ps_attribute_lang.name,'')) AS Size, ma

我试图建立一个报告,其中显示所有产品及其属性,功能和它所属的类别。但我写的查询需要很多时间。我如何改进这一点

[CODE]

SELECT   max(if((ps_attribute_group_lang.name like "Color"),ps_attribute_lang.name,'')) AS Color, max(if((ps_attribute_group_lang.name like "Size"),ps_attribute_lang.name,'')) AS Size, max(if((ps_feature_lang.name like "Brand"),ps_feature_value_lang.value,'')) AS Brand, max(if((ps_feature_lang.name like "Sub brand"),ps_feature_value_lang.value,'')) AS Subbrand, max(if((ps_feature_lang.name like "Occasion"),ps_feature_value_lang.value,'')) AS Occasion, max(if((ps_feature_lang.name like "Sleeves"),ps_feature_value_lang.value,'')) AS Sleeves, max(if((ps_feature_lang.name like "Cuffs"),ps_feature_value_lang.value,'')) AS Cuffs, max(if((ps_feature_lang.name like "Collar"),ps_feature_value_lang.value,'')) AS Collar, max(if((ps_feature_lang.name like "Neck"),ps_feature_value_lang.value,'')) AS Neck, max(if((ps_feature_lang.name like "Hood"),ps_feature_value_lang.value,'')) AS Hood, max(if((ps_feature_lang.name like "Shoulder"),ps_feature_value_lang.value,'')) AS Shoulder, max(if((ps_feature_lang.name like "Straps"),ps_feature_value_lang.value,'')) AS Straps, max(if((ps_feature_lang.name like "Trouser Front"),ps_feature_value_lang.value,'')) AS TrouserFront, max(if((ps_feature_lang.name like "Front Opening"),ps_feature_value_lang.value,'')) AS FrontOpening, max(if((ps_feature_lang.name like "Suit Front"),ps_feature_value_lang.value,'')) AS SuitFront, max(if((ps_feature_lang.name like "Fit"),ps_feature_value_lang.value,'')) AS Fit, max(if((ps_feature_lang.name like "Wash"),ps_feature_value_lang.value,'')) AS Wash, max(if((ps_feature_lang.name like "Length"),ps_feature_value_lang.value,'')) AS Length, max(if((ps_feature_lang.name like "Style"),ps_feature_value_lang.value,'')) AS Style, max(if((ps_feature_lang.name like "Pattern"),ps_feature_value_lang.value,'')) AS Pattern, max(if((ps_feature_lang.name like "Weatherproof"),ps_feature_value_lang.value,'')) AS Weatherproof, max(if((ps_feature_lang.name like "Fabric Type"),ps_feature_value_lang.value,'')) AS FabricType, max(if((ps_feature_lang.name like "Suit Type"),ps_feature_value_lang.value,'')) AS SuitType, max(if((ps_feature_lang.name like "Accessories"),ps_feature_value_lang.value,'')) AS Accessories, max(if((ps_feature_lang.name like "Fashion Accessories"),ps_feature_value_lang.value,'')) AS FashionAccessories, max(if((ps_feature_lang.name like "Shoe Type"),ps_feature_value_lang.value,'')) AS ShoeType, max(if((ps_feature_lang.name like "Bag Type"),ps_feature_value_lang.value,'')) AS BagType, max(if((ps_feature_lang.name like "Material"),ps_feature_value_lang.value,'')) AS Material, max(if((ps_feature_lang.name like "Ethnic Bottom Style "),ps_feature_value_lang.value,'')) AS EthnicBottomStyle,  ps_product_attribute.id_product AS productid,
`ps_product_lang`.`name` AS `productname`,
`ps_product_attribute`.`ean13`         AS `a_ean13`,
`ps_category_lang`.`name`              AS `categoryname`,
`ps_product_attribute`.`id_product_attribute`  AS `id_product_attribute`,
`t_vendorproducts`.`a_vendorid`        AS `vendorid`,
round(`ps_product`.`price`,2)  AS price   from
        (((((((`ps_product_attribute`
        join `ps_product_lang`          ON ((`ps_product_lang`.`id_product` = `ps_product_attribute`.`id_product`)))
        join `ps_product_attribute_combination` ON ((`ps_product_attribute_combination`.`id_product_attribute` = `ps_product_attribute`.`id_product_attribute`)))
        join `ps_attribute`            ON ((`ps_attribute`.`id_attribute` = `ps_product_attribute_combination`.`id_attribute`)))
        join `ps_attribute_lang`        ON ((`ps_attribute_lang`.`id_attribute` = `ps_product_attribute_combination`.`id_attribute`)))
        join `ps_attribute_group_lang`   ON (((`ps_attribute`.`id_attribute_group` = `ps_attribute_group_lang`.`id_attribute_group`))))))
        join  ps_feature_product        on ps_feature_product.id_product = ps_product_attribute.id_product
    join  ps_feature_value_lang      on ps_feature_value_lang.id_feature_value = ps_feature_product.id_feature_value
        join  ps_feature_lang           on ps_feature_product.id_feature = ps_feature_lang.id_feature
        join  ps_product               on ps_product.id_product = ps_product_attribute.id_product
    join  ps_category  cate1       on cate1.id_category = ps_product.id_category_default
    join  ps_category  cate2       on cate2.id_category = cate1.id_parent
    join  ps_category_lang        on ps_category_lang.id_category = cate1.id_category
   WHERE  ps_product_lang.id_shop = 1  GROUP BY ps_product_attribute.ean13 ORDER BY productid

[/CODE]
下面是解释的内容

"id"    "select_type"   "table" "type"  "possible_keys" "key"   "key_len"   "ref"   "rows"  "Extra"
"1" "SIMPLE"    "ps_product"    "index" "PRIMARY"   "id_category_default"   "5" \N  "5481"  "Using index; Using temporary; Using filesort"
"1" "SIMPLE"    "pa"    "ref"   "product_attribute_product,product_default" "product_attribute_product" "4" "mycode.ps_product.id_product"  "2" "Using index"
"1" "SIMPLE"    "pac"   "ref"   "id_product_attribute"  "id_product_attribute"  "4" "mycode.pa.id_product_attribute"    "1" "Using index"
"1" "SIMPLE"    "a" "eq_ref"    "PRIMARY"   "PRIMARY"   "4" "mycode.pac.id_attribute"   "1" ""
"1" "SIMPLE"    "ag"    "eq_ref"    "PRIMARY"   "PRIMARY"   "4" "mycode.a.id_attribute_group"   "1" "Using index"
"1" "SIMPLE"    "al"    "eq_ref"    "PRIMARY,id_lang"   "PRIMARY"   "8" "mycode.a.id_attribute,const"   "1" ""
"1" "SIMPLE"    "agl"   "eq_ref"    "PRIMARY"   "PRIMARY"   "8" "mycode.ag.id_attribute_group,const"    "1" ""
"1" "SIMPLE"    "ps_feature_product"    "ref"   "id_product"    "id_product"    "4" "mycode.pa.id_product"  "1" ""
"1" "SIMPLE"    "ps_feature_value_lang" "eq_ref"    "PRIMARY,ps_feature_value_lang_lang"    "PRIMARY"   "8" "mycode.ps_feature_product.id_feature_value,const"  "1" ""
"1" "SIMPLE"    "ps_feature_lang"   "eq_ref"    "PRIMARY,id_lang"   "PRIMARY"   "8" "mycode.ps_feature_product.id_feature,const"    "1" ""
"1" "SIMPLE"    "cate1" "eq_ref"    "PRIMARY"   "PRIMARY"   "4" "mycode.ps_product.id_category_default" "1" ""
"1" "SIMPLE"    "cate2" "eq_ref"    "PRIMARY"   "PRIMARY"   "4" "mycode.cate1.id_parent"    "1" "Using index"
"1" "SIMPLE"    "ps_category_lang"  "ref"   "PRIMARY,ps_category_lang_ID_CATEGORY"  "ps_category_lang_ID_CATEGORY"  "4" "mycode.cate1.id_category"  "2" "Using index"
"1" "SIMPLE"    "ps_product_lang"   "ref"   "PRIMARY"   "PRIMARY"   "4" "mycode.ps_product.id_product"  "3" "Using index"

嗯,不用了,谢谢,不过祝你好运。哦,好的-有两件事1)使用“=”进行等式比较。使用“相似”进行“相似”比较。2) 要想获得进一步的帮助,您需要提供一个解释。如果您的数据库的配置变量不是最优的,您应该将innodb_buffer_pool变量增加到一个更大的值。很好。还有一件事,你为什么把价格四舍五入?价格的存储精度是否高于0.00?