SQL:无法连接这两个表(EAV Architechture,Magento)
SQL: Unable To Join These Two Tables (EAV Architechture, Magento)
以下查询为我获取 entity_id 和名称列
SELECT e.entity_id, eav.value AS name
FROM catalog_product_entity e
JOIN catalog_product_entity_varchar eav
ON e.entity_id = eav.entity_id
JOIN eav_attribute ea
ON eav.attribute_id = ea.attribute_id
WHERE ea.attribute_code = 'name'
以下查询为我提供了 entity_id 和价格列
SELECT e.entity_id, eav.value AS price
FROM catalog_product_entity e
JOIN catalog_product_entity_decimal eav
ON e.entity_id = eav.entity_id
JOIN eav_attribute ea
ON eav.attribute_id = ea.attribute_id
WHERE ea.attribute_code = 'price'
我无法加入这两个,无法同时获得 entity_id、名称和价格列,有人可以帮我解决这个问题吗?
尝试:
SELECT e.entity_id, eav.value AS name, eav2.value as price
FROM catalog_product_entity e
JOIN catalog_product_entity_varchar eav
ON e.entity_id = eav.entity_id
JOIN eav_attribute ea
ON eav.attribute_id = ea.attribute_id
JOIN catalog_product_entity_decimal eav2
ON e.entity_id = eav2.entity_id
JOIN eav_attribute ea2
ON eav2.attribute_id = ea2.attribute_id
WHERE ea.attribute_code = 'name'
and ea2.attribute_code = 'price'
以下查询为我获取 entity_id 和名称列
SELECT e.entity_id, eav.value AS name
FROM catalog_product_entity e
JOIN catalog_product_entity_varchar eav
ON e.entity_id = eav.entity_id
JOIN eav_attribute ea
ON eav.attribute_id = ea.attribute_id
WHERE ea.attribute_code = 'name'
以下查询为我提供了 entity_id 和价格列
SELECT e.entity_id, eav.value AS price
FROM catalog_product_entity e
JOIN catalog_product_entity_decimal eav
ON e.entity_id = eav.entity_id
JOIN eav_attribute ea
ON eav.attribute_id = ea.attribute_id
WHERE ea.attribute_code = 'price'
我无法加入这两个,无法同时获得 entity_id、名称和价格列,有人可以帮我解决这个问题吗?
尝试:
SELECT e.entity_id, eav.value AS name, eav2.value as price
FROM catalog_product_entity e
JOIN catalog_product_entity_varchar eav
ON e.entity_id = eav.entity_id
JOIN eav_attribute ea
ON eav.attribute_id = ea.attribute_id
JOIN catalog_product_entity_decimal eav2
ON e.entity_id = eav2.entity_id
JOIN eav_attribute ea2
ON eav2.attribute_id = ea2.attribute_id
WHERE ea.attribute_code = 'name'
and ea2.attribute_code = 'price'