The following MySQL query returns all Magento orders that have at least one item with attribute set id 9.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
/* 9 = attribute set Id */ select increment_id, created_at, entity_id from sales_flat_order where entity_id not in ( SELECT o.entity_id FROM sales_flat_order o LEFT JOIN sales_flat_order_item i ON o.entity_id = i.order_id LEFT JOIN catalog_product_entity p ON i.product_id = p.entity_id WHERE p.attribute_set_id = 9 ) |