Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 从magento数据库获取客户姓名和电子邮件_Mysql_Magento - Fatal编程技术网

Mysql 从magento数据库获取客户姓名和电子邮件

Mysql 从magento数据库获取客户姓名和电子邮件,mysql,magento,Mysql,Magento,我正在尝试从我们在magento的客户那里获取所有姓名和电子邮件 我有以下代码,但我不知道如何获得电子邮件 SELECT entity_id, GROUP_CONCAT( VALUE SEPARATOR ' ' ) AS fullname FROM customer_address_entity_varchar AS val INNER JOIN eav_attribute AS attr ON attr.attribute_id = val.attribute_id WHERE attr.a

我正在尝试从我们在magento的客户那里获取所有姓名和电子邮件

我有以下代码,但我不知道如何获得电子邮件

SELECT entity_id, GROUP_CONCAT( VALUE
SEPARATOR  ' ' ) AS fullname
FROM customer_address_entity_varchar AS val
INNER JOIN eav_attribute AS attr ON attr.attribute_id = val.attribute_id
WHERE attr.attribute_code
IN (
'firstname',  'lastname',  'email'
)
GROUP BY entity_id
LIMIT 0 , 30

电子邮件存储在
customer\u entity
表中,而不是eav表中

请改为尝试此查询:

select ce.entity_id, concat(cevf.value, ' ', cevl.value) fullname, ce.email
from customer_entity ce
inner join customer_entity_varchar cevf
    on ce.entity_id = cevf.entity_id
inner join eav_attribute eaf
    on eaf.attribute_id = cevf.attribute_id
inner join customer_entity_varchar cevl
    on ce.entity_id = cevl.entity_id
inner join eav_attribute eal
    on eal.attribute_id = cevl.attribute_id
inner join eav_entity_type eet
    on eet.entity_type_id = eal.entity_type_id = eaf.entity_type_id
where
    eet.entity_type_code = 'customer'
    and eaf.attribute_code = 'firstname'
    and eal.attribute_code = 'lastname'
order by ce.entity_id

如果您对此感兴趣,可以通过PHP和Magento的工厂方法来实现

<?php

include 'app/Mage.php';
Mage::app();
$customerCollection = Mage::getModel('customer/customer')
    ->getCollection()
    ->addAttributeToSelect('firstname')
    ->addAttributeToSelect('lastname');
echo $customerCollection->getSelect();
// foreach ($customerCollection as $customer) print_r($customer->getData());

电子邮件存储在
customer\u entity
表中,而不是eav表中

请改为尝试此查询:

select ce.entity_id, concat(cevf.value, ' ', cevl.value) fullname, ce.email
from customer_entity ce
inner join customer_entity_varchar cevf
    on ce.entity_id = cevf.entity_id
inner join eav_attribute eaf
    on eaf.attribute_id = cevf.attribute_id
inner join customer_entity_varchar cevl
    on ce.entity_id = cevl.entity_id
inner join eav_attribute eal
    on eal.attribute_id = cevl.attribute_id
inner join eav_entity_type eet
    on eet.entity_type_id = eal.entity_type_id = eaf.entity_type_id
where
    eet.entity_type_code = 'customer'
    and eaf.attribute_code = 'firstname'
    and eal.attribute_code = 'lastname'
order by ce.entity_id

如果您对此感兴趣,可以通过PHP和Magento的工厂方法来实现

<?php

include 'app/Mage.php';
Mage::app();
$customerCollection = Mage::getModel('customer/customer')
    ->getCollection()
    ->addAttributeToSelect('firstname')
    ->addAttributeToSelect('lastname');
echo $customerCollection->getSelect();
// foreach ($customerCollection as $customer) print_r($customer->getData());

任何示例数据集加上所需结果集?请参见答案下方评论中的屏幕截图,我想要名称和电子邮件,仅此而已,但下面的sql代码似乎不正确。有什么想法吗?谢谢,如果您能在这里提供示例数据集,我会尽我最大的努力。任何示例数据集加上所需的结果集?请参阅答案下方评论中的屏幕热,我想要名称和电子邮件,仅此而已,但下面的sql代码似乎不正确。请您有什么想法?谢谢,如果您能提供示例数据集,我会尽我最大的努力。我认为连接有问题,您能帮忙吗?我发自内心地知道,下面截图中nancy@的名字不正确。我想接头有问题,你能帮忙吗?我发自内心地知道,下面截图中nancy@的名字不正确。