如何在选择查询中使用联接创建视图

时间:2019-05-09 12:13:08

标签: mysql sql mariadb

无法使用查询创建视图

将更改应用于属性错误1349:视图的SELECT在FROM子句SQL语句中包含一个子查询:

请建议我如何使用此查询创建视图

CREATE view `attribute` 
AS 
  SELECT av11.category_id, 
         av11.frontend_label AS label, 
         Group_concat(DISTINCT avov11.value ORDER BY avov11.value DESC SEPARATOR 
            ',') 
                             options 
  FROM   (SELECT eav_attribute.attribute_id, 
                 eav_attribute.frontend_label, 
                 catalog_category_product.category_id 
          FROM   eav_attribute 
                 JOIN eav_entity_attribute 
                   ON eav_attribute.attribute_id = 
                      eav_entity_attribute.attribute_id 
                 JOIN catalog_eav_attribute 
                   ON eav_attribute.attribute_id = 
                      catalog_eav_attribute.attribute_id 
                      AND catalog_eav_attribute.is_filterable = 1 
                 JOIN catalog_product_entity 
                   ON eav_entity_attribute.attribute_set_id = 
                      catalog_product_entity.attribute_set_id 
                 JOIN catalog_category_product 
                   ON catalog_product_entity.entity_id = 
                      catalog_category_product.product_id 
          GROUP  BY eav_attribute.attribute_id) av11 
         JOIN eav_attribute_option avo11 
           ON av11.attribute_id = avo11.attribute_id 
         JOIN eav_attribute_option_value avov11 
           ON avo11.option_id = avov11.option_id 
  GROUP  BY av11.frontend_label; 

0 个答案:

没有答案