Forums / General Questions / How to remove all customers who have never ordered before?

How to remove all customers who have never ordered before?

Started by ebookba on 5 Sep 2011, 12:31 AM · Views: 6,025

Results 21 to 22 of 22
12 Jan 2018, 12:58 PM
#21
jakelawless avatar

jakelawless

Zen Follower

Join Date:
Jan 2018
Posts:
146
Plugin Contributions:
0

How to remove all customers who have never ordered before?

fakeDecoy:

FYI, my queries to delete customers with zero lifetime orders and with no activity for 6 months:

DELETE from zen_customers
WHERE customers_id IN
(SELECT customers_info_id from zen_customers_info where TIMESTAMPDIFF(MONTH,customers_info_date_account_created, NOW()) > 6
AND TIMESTAMPDIFF(MONTH,customers_info_date_of_last_logon, NOW()) > 6)
AND customers_id NOT IN
(SELECT customers_id FROM zen_orders);

update zen_reviews set customers_id = null where customers_id not in (select customers_id from zen_customers);
delete from zen_address_book where customers_id not in (select customers_id from zen_customers);
delete from zen_customers_info where customers_info_id not in (select customers_id from zen_customers);
delete from zen_customers_basket where customers_id not in (select customers_id from zen_customers);
delete from zen_customers_basket_attributes where customers_id not in (select customers_id from zen_customers);
delete from zen_whos_online where customer_id not in (select customers_id from zen_customers);
delete from zen_products_notifications where customers_id not in (select customers_id from zen_customers);


Which php file on the ftp does this code go in to?
12 Jan 2018, 1:45 PM
#22
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: How to remove all customers who have never ordered before?

JakeLawless:

Which php file on the ftp does this code go in to?

JakeLawless:

Which php file on the ftp does this code go in to?

It doesn't have to go into a file, instead executed from tools->install sql patches or with consideration of table prefix through your "favorite" database sql editor.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...