网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 服务器与数据库 > MySQL
User Name
Password
 
FAQ Members List Calendar Cheap Glasses Mark Forums Read

Reply
 
Thread Tools Display Modes
  #1   IP: 121.234.209.73
Old 2012-11-30, 04:15 PM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default getting customer info from magento table structure

I want to get rows for all customer details from magento tables.

Can anyone give me the query?

Tables are:
•customer_entity
•eav_attribute
•customer_entity_varchar'



Answer A:

Code:
SELECT 
`firstname`.`value` as `First_Name`, 
`surname`.`value` as `Surname`, 
`telephone`.`value` as `Telephone`,
`customer_entity`.`created_at`,
`customer_entity`.`updated_at` 
FROM 
`customer_address_entity_varchar` as `country` 
INNER JOIN 
`customer_address_entity_varchar` as  `firstname` USING (`entity_id`) 
INNER JOIN 
`customer_address_entity_varchar` as  `surname` USING (`entity_id`) 
INNER JOIN 
`customer_address_entity_varchar` as  `telephone` USING (`entity_id`) 
INNER JOIN 
`customer_entity` USING (`entity_id`) 
WHERE 
`country`.`attribute_id` = 26 && 
`country`.`value`="GB" && 
`firstname`.`attribute_id` = 19  && 
`surname`.`attribute_id` = 21  && 
`telephone`.`attribute_id` = 30  && 
`telephone`.`value` LIKE "07%"  
GROUP BY `telephone`.`value` 
limit 0,10;


useful code a: GROUP BY `customer_entity`.`email`


Code:
SELECT 
`firstname`.`value` as `First_Name`, 
`surname`.`value` as `Surname`, 
`customer_entity`.`email`
FROM 
`customer_address_entity_varchar` as `country` 
INNER JOIN 
`customer_address_entity_varchar` as  `firstname` USING (`entity_id`) 
INNER JOIN 
`customer_address_entity_varchar` as  `surname` USING (`entity_id`)  
INNER JOIN 
`customer_entity` USING (`entity_id`) 
WHERE 
`country`.`attribute_id` = 26 && 
`country`.`value`="US" && 
`firstname`.`attribute_id` = 19  && 
`surname`.`attribute_id` = 21  
GROUP BY `customer_entity`.`email`
limit 0,10;

code b: GROUP BY `entity_id`

Code:
SELECT 
`entity_id`,
`firstname`.`value` as `First_Name`, 
`surname`.`value` as `Surname`, 
`customer_entity`.`email`
FROM 
`customer_address_entity_varchar` as `country` 
INNER JOIN 
`customer_address_entity_varchar` as  `firstname` USING (`entity_id`) 
INNER JOIN 
`customer_address_entity_varchar` as  `surname` USING (`entity_id`)  
INNER JOIN 
`customer_entity` USING (`entity_id`) 
WHERE 
`country`.`attribute_id` = 26 && 
`country`.`value`="US" && 
`firstname`.`attribute_id` = 19  && 
`surname`.`attribute_id` = 21  
GROUP BY `entity_id`
limit 0,10;
useful code c, 将查出的结果保存到一个新表

Code:
create table aaa_custoemr SELECT 
`entity_id`,
`firstname`.`value` as `First_Name`, 
`surname`.`value` as `Surname`, 
`customer_entity`.`email`
FROM 
`customer_address_entity_varchar` as `country` 
INNER JOIN 
`customer_address_entity_varchar` as  `firstname` USING (`entity_id`) 
INNER JOIN 
`customer_address_entity_varchar` as  `surname` USING (`entity_id`)  
INNER JOIN 
`customer_entity` USING (`entity_id`) 
WHERE 
`country`.`attribute_id` = 26 && 
`country`.`value`="US" && 
`firstname`.`attribute_id` = 19  && 
`surname`.`attribute_id` = 21  
GROUP BY `entity_id`
limit 0,10000;

answer 01: create table dust select * from student;//用于复制前未创建新表dust的情况下 answer 02: insert into dust select * from student;//已经创建了新表dust的情况下

Last edited by topvip : 2012-12-01 at 09:55 PM
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
x-cart Template Editing Guide for 4.1.x topvip X-Cart 0 2009-04-15 11:42 PM
Template Editing Guide for 4.1.x topvip X-Cart 0 2009-03-10 08:12 AM
What are the Strongest Directories? smiling 网站链接开发 1 2007-07-28 09:26 PM

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 12:32 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.