mysql查询magento连续左连接问题

cbjzeqam  于 2021-08-13  发布在  Java
关注(0)|答案(1)|浏览(470)

我的查询没有给出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"

它应该给我的电子邮件和公司价值为空,如果它不存在,但它给我什么,如果没有公司名称。

mkshixfv

mkshixfv1#

请对customer\u address\u 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;

相关问题