我想就我的问题寻求帮助。我有一个查询,它从数据库中提取数据(sku、产品名称和产品描述)。我这样做是因为我正在尝试创建某种报告工具的扩展,尽管它目前只是供个人使用。
我需要的是:
sku、产品名称、产品描述、售出数量、成本价、售价
那些粗体字,我已经成功地从dbase中提取出来了。我想寻求任何帮助来拉动剩下的3个。销售数量是该产品所有完整订单的总和。
这是我迄今为止使用的代码。
SELECT
`e`.`sku`,
IF(at_name.value_id > 0, at_name.value, at_name_default.value) AS `name`,
IF(at_description.value_id > 0, at_description.value, at_description_default.value) AS `description`
FROM
`mgob_catalog_product_entity` AS `e`
INNER JOIN
`mgob_catalog_product_entity_varchar` AS `at_name_default`
ON (`at_name_default`.`entity_id` = `e`.`entity_id`) AND
(`at_name_default`.`attribute_id` = (SELECT attribute_id FROM `mgob_eav_attribute` ea LEFT JOIN `mgob_eav_entity_type` et ON ea.entity_type_id = et.entity_type_id WHERE `ea`.`attribute_code` = 'name' AND et.entity_type_code = 'catalog_product')) AND
`at_name_default`.`store_id` = 0
LEFT JOIN
`mgob_catalog_product_entity_varchar` AS `at_name`
ON (`at_name`.`entity_id` = `e`.`entity_id`) AND
(`at_name`.`attribute_id` = (SELECT attribute_id FROM `mgob_eav_attribute` ea LEFT JOIN `mgob_eav_entity_type` et ON ea.entity_type_id = et.entity_type_id WHERE `ea`.`attribute_code` = 'name' AND et.entity_type_code = 'catalog_product')) AND
(`at_name`.`store_id` = 1)
INNER JOIN
`mgob_catalog_product_entity_text` AS `at_description_default`
ON (`at_description_default`.`entity_id` = `e`.`entity_id`) AND
(`at_description_default`.`attribute_id` = (SELECT attribute_id FROM `mgob_eav_attribute` ea LEFT JOIN `mgob_eav_entity_type` et ON ea.entity_type_id = et.entity_type_id WHERE `ea`.`attribute_code` = 'description' AND et.entity_type_code = 'catalog_product')) AND
`at_description_default`.`store_id` = 0
LEFT JOIN
`mgob_catalog_product_entity_text` AS `at_description`
ON (`at_description`.`entity_id` = `e`.`entity_id`) AND
(`at_description`.`attribute_id` = (SELECT attribute_id FROM `mgob_eav_attribute` ea LEFT JOIN `mgob_eav_entity_type` et ON ea.entity_type_id = et.entity_type_id WHERE `ea`.`attribute_code` = 'description' AND et.entity_type_code = 'catalog_product')) AND
(`at_description`.`store_id` = 1) "
暂无答案!
目前还没有任何答案,快来回答吧!