sql Magento的,以客户为view.sql

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql Magento的,以客户为view.sql相关的知识,希望对你有一定的参考价值。

CREATE VIEW customer_view AS

SELECT    e.entity_id,
          e.group_id,
          e.store_id,
          e.website_id,
          e.email,
          confirmation.value                  AS confirmation,
          created_in.value                    AS created_in,
          default_billing.value               AS default_billing,
          default_shipping.value              AS default_shipping,
          dob.value                           AS dob,
          firstname.value                     AS firstname,
          gender.value                        AS gender,
          lastname.value                      AS lastname,
          middlename.value                    AS middlename,
          old_referral_rule_ids.value         AS old_referral_rule_ids,
          password_hash.value                 AS password_hash,
          prefix.value                        AS prefix,
          reward_update_notification.value    AS reward_update_notification,
          reward_warning_notification.value   AS reward_warning_notification,
          suffix.value                        AS suffix,
          taxvat.value                        AS taxvat,
          e.created_at,
          e.updated_at
FROM      customer_entity           AS e
LEFT JOIN customer_entity_varchar   AS confirmation                 ON (confirmation.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE entity_type_id = e.entity_type_id AND attribute_code = 'confirmation') AND confirmation.entity_id = e.entity_id)
LEFT JOIN customer_entity_varchar   AS created_in                   ON (created_in.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE entity_type_id = e.entity_type_id AND attribute_code = 'created_in') AND created_in.entity_id = e.entity_id)
LEFT JOIN customer_entity_int       AS default_billing              ON (default_billing.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE entity_type_id = e.entity_type_id AND attribute_code = 'default_billing') AND default_billing.entity_id = e.entity_id)
LEFT JOIN customer_entity_int       AS default_shipping             ON (default_shipping.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE entity_type_id = e.entity_type_id AND attribute_code = 'default_shipping') AND default_shipping.entity_id = e.entity_id)
LEFT JOIN customer_entity_datetime  AS dob                          ON (dob.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE entity_type_id = e.entity_type_id AND attribute_code = 'dob') AND dob.entity_id = e.entity_id)
LEFT JOIN customer_entity_varchar   AS firstname                    ON (firstname.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE entity_type_id = e.entity_type_id AND attribute_code = 'firstname') AND firstname.entity_id = e.entity_id)
LEFT JOIN customer_entity_int       AS gender                       ON (gender.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE entity_type_id = e.entity_type_id AND attribute_code = 'gender') AND gender.entity_id = e.entity_id)
LEFT JOIN customer_entity_varchar   AS lastname                     ON (lastname.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE entity_type_id = e.entity_type_id AND attribute_code = 'lastname') AND lastname.entity_id = e.entity_id)
LEFT JOIN customer_entity_varchar   AS middlename                   ON (middlename.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE entity_type_id = e.entity_type_id AND attribute_code = 'middlename') AND middlename.entity_id = e.entity_id)
LEFT JOIN customer_entity_text      AS old_referral_rule_ids        ON (old_referral_rule_ids.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE entity_type_id = e.entity_type_id AND attribute_code = 'old_referral_rule_ids') AND old_referral_rule_ids.entity_id = e.entity_id)
LEFT JOIN customer_entity_varchar   AS password_hash                ON (password_hash.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE entity_type_id = e.entity_type_id AND attribute_code = 'password_hash') AND password_hash.entity_id = e.entity_id)
LEFT JOIN customer_entity_varchar   AS prefix                       ON (prefix.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE entity_type_id = e.entity_type_id AND attribute_code = 'prefix') AND prefix.entity_id = e.entity_id)
LEFT JOIN customer_entity_int       AS reward_update_notification   ON (reward_update_notification.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE entity_type_id = e.entity_type_id AND attribute_code = 'reward_update_notification') AND reward_update_notification.entity_id = e.entity_id)
LEFT JOIN customer_entity_int       AS reward_warning_notification  ON (reward_warning_notification.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE entity_type_id = e.entity_type_id AND attribute_code = 'reward_warning_notification') AND reward_warning_notification.entity_id = e.entity_id)
LEFT JOIN customer_entity_varchar   AS suffix                       ON (suffix.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE entity_type_id = e.entity_type_id AND attribute_code = 'suffix') AND suffix.entity_id = e.entity_id)
LEFT JOIN customer_entity_varchar   AS taxvat                       ON (taxvat.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE entity_type_id = e.entity_type_id AND attribute_code = 'taxvat') AND taxvat.entity_id = e.entity_id);

以上是关于sql Magento的,以客户为view.sql的主要内容,如果未能解决你的问题,请参考以下文章

sql Magento 1 - SQL获取每个客户的销售和订单总数

sql Magento - 删除所有客户

sql 截断客户magento

sql 截断Magento2订单和客户数据

sql 清除所有Magento 1.9。*客户/订单数据

sql Magento 2截断客户,产品,评论和订单表