Я модифицировал отличный ответ Андрея Церкуса.И добавил новое предложение WHERE.Теперь вам нужно просто заменить SKU продукта, и вы получите все записи клиентов, которые купили продукт У меня отлично работает в Magento 1.5.1
/* Just replace the value for i.sku in line 32, with the corresponding sku of the product you want to get the buyers from*/
SELECT
`e`.*,
`at_prefix`.`value` AS `prefix`,
`at_firstname`.`value` AS `firstname`,
`at_middlename`.`value` AS `middlename`,
`at_lastname`.`value` AS `lastname`,
`at_suffix`.`value` AS `suffix`,
CONCAT(IF(at_prefix.value IS NOT NULL AND at_prefix.value != '',
CONCAT(LTRIM(RTRIM(at_prefix.value)), ' '),
''),
LTRIM(RTRIM(at_firstname.value)), ' ',
IF(at_middlename.value IS NOT NULL AND at_middlename.value != '',
CONCAT(LTRIM(RTRIM(at_middlename.value)), ' '),
''),
LTRIM(RTRIM(at_lastname.value)),
IF(at_suffix.value IS NOT NULL AND at_suffix.value != '',
CONCAT(' ', LTRIM(RTRIM(at_suffix.value))),
'')
) AS `name`
FROM `customer_entity` AS `e`
LEFT JOIN `customer_entity_varchar` AS `at_prefix` ON (`at_prefix`.`entity_id` = `e`.`entity_id`) AND (`at_prefix`.`attribute_id` = '4')
LEFT JOIN `customer_entity_varchar` AS `at_firstname` ON (`at_firstname`.`entity_id` = `e`.`entity_id`) AND (`at_firstname`.`attribute_id` = '5')
LEFT JOIN `customer_entity_varchar` AS `at_middlename` ON (`at_middlename`.`entity_id` = `e`.`entity_id`) AND (`at_middlename`.`attribute_id` = '6')
LEFT JOIN `customer_entity_varchar` AS `at_lastname` ON (`at_lastname`.`entity_id` = `e`.`entity_id`) AND (`at_lastname`.`attribute_id` = '7')
LEFT JOIN `customer_entity_varchar` AS `at_suffix` ON (`at_suffix`.`entity_id` = `e`.`entity_id`) AND (`at_suffix`.`attribute_id` = '8')
WHERE (`e`.`entity_type_id` = '1')
AND `e`.`entity_id` IN (
SELECT DISTINCT o.customer_id FROM sales_flat_order_item i
INNER JOIN sales_flat_order o ON o.entity_id = i.order_id
WHERE o.customer_id IS NOT NULL
AND i.sku = '10-10-10101-4'
)
LIMIT 1000