
Originally Posted by
dysfunctional
I still get the exact same list of customers where some of them actually did buy the product at some point. They may have a few orders not containing this specific product though and maybe this query lists those orders?
Yes. That'll be it. The SQL query to take these into account would be quite complex. It will probably be quicker for you to manually identify and delete those email addresses than it would for me to nut out a suitable query.
OTOH, try this:
Code:
SELECT distinct `customers_id`, `customers_email_address`,`customers_country` from `orders` join `orders_products` on `products_id` != '114'

Originally Posted by
dysfunctional
And it this would be even better if the list could contain customers country too, next to the e-mail address. I tried to accomplish this but my knowledge in SQL is way too poor obviously :)
If the code above doesn't work as expected, the older code can be modified as follows to include the country.
Code:
SELECT DISTINCT `customers_email_address`, `customers_country` FROM `orders` WHERE `orders_id` IN
(SELECT `orders_id` FROM `orders_products` WHERE `products_id` != '114' )
Cheers
Rod
Bookmarks