
Originally Posted by
jc8125
your results may vary, but this seems to be working on a few test shops i've tried:
Code:
select DISTINCT customers_email_address, customers_id, customers_country from orders where customers_id NOT IN (select DISTINCT o.customers_id from orders o, orders_products op where o.orders_id = op.orders_id and products_id = "114")
On my test db, there are 11 customers who have ordered. 2 of them have ordered that product, 9 haven't. When I run the above query, I get the list of the 9 who haven't ordered the item.
Wow, this script worked for me. Now I get a list of customers who did not purchase the product in question. Awesome!
But, when I "Select all" in phpmyadmin and click "Export" (to csv), instead of getting a normal .csv I get a csv file formatted to html.
When I rename it to html and run it in a browser it says :
Code:
mysqlserver - DBcrashdiet - zen_orders
Error
SQL query: DocumentationEdit Edit
SELECT DISTINCT o.customers_id FROM zen_orders o , zen_orders_products op WHERE ((`zen_orders`.`customers_email_address` = '[email protected]' AND `zen_orders`.`customers_id` = 51 AND `zen_orders`.`customers_country` = 'Germany') OR (`zen_orders`.`customers_email_address` = 'emailadress##########################' AND `zen_orders`.`customers_id` = 37 AND `zen_orders`.`customers_country` = 'United Kingdom') OR (`zen_orders`.`customers_email_address` = 'cobey####################.au' AND `zen_orders`.`customers_id` = 103 AND `zen_orders`.`customers_country` = 'Sweden') OR (`zen_orders`.`customers_email_address` = 'sapphirehaze_##########################' AND `zen_orders`.`customers_id` = 58 AND `zen_orders`.`customers_country` = 'Australia') OR (`zen_orders`.`customers_email_address` = 'ludwig.halldin##########################' AND `zen_orders`.`customers_id` = 154 AND `zen_orders`.`customers_country` = 'Sweden') OR (`zen_orders`.`customers_email_address` = '[email protected]' AND `zen_orders`.`customers_id` = 135 AND `zen_orders`.`custom[...]
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
(I did some changes to not reveal my customers e-mail addresses)
I've done loads of csv-exports before but this time I can't seem to get it right.
As always I'd truly appreciate any help I can get. Thank you
Regards Peter
Bookmarks