[英]mysql query magento consecutive left join problem
我有这个查询没有给我 magento 1.9 数据库的预期结果:
SELECT
customer.email AS email,
company.value as comp
FROM customer_entity AS customer
JOIN customer_address_entity AS addressentity
ON customer.entity_id=addressentity.parent_id
LEFT JOIN customer_address_entity_varchar AS company
ON company.entity_id=addressentity.entity_id
WHERE
customer.store_id = 1 AND
company.attribute_id=24 AND
customer.email="this@mail.com"
如果它不存在,它应该给我 email 和公司价值为 null 但如果没有公司名称,它什么也不给我。
请对 customer_address_entity 表也使用左外连接,
SELECT
customer.email AS email,
company.value as comp
FROM customer_entity AS customer
FULL OUTER JOIN customer_address_entity AS addressentity
ON customer.entity_id=addressentity.parent_id
FULL OUTER JOIN customer_address_entity_varchar AS company
ON company.entity_id=addressentity.entity_id;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.