1

what is the safest way to delete spam customers specific date/email using MySQL?

For example delete all customers with email example.com and from 9/15/2018 to 9/28/2018

I cant use back-end UI to delete the records because hosting limitation resources and its gives.

Warning: Error while sending QUERY packet. PID=28451 in /home/got52/public_html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php on line 228

So anyone have the mysql query doing that? Thanks

6
  • Do you want to delete it directly from the database ? Commented Sep 28, 2018 at 18:24
  • Using sql query ? Commented Sep 28, 2018 at 18:24
  • @AdityaShah Yes, but in safest way.
    – MagEGY
    Commented Sep 28, 2018 at 18:30
  • Yeah try select query first to see if it will delete the correct rows Commented Sep 28, 2018 at 18:31
  • please mark as right if it solves your query. Commented Sep 28, 2018 at 21:10

1 Answer 1

0

[Note]: Please take database backup prior to executing these queries.

First check Query using SELECT - to see if it will delete the correct rows

SELECT * from customers
WHERE email like '%example.com'
and date_created between CAST('2018-09-15' AS DATE) AND CAST('2018-09-28' AS DATE);

Then

DELETE customers
where email like '%example.com'
and date_created between CAST('2018-09-15' AS DATE) AND CAST('2018-09-28' AS DATE);

Customer tables

`customer_address_entity`;
`customer_address_entity_datetime`;
`customer_address_entity_decimal`;
`customer_address_entity_int`;
`customer_address_entity_text`;
`customer_address_entity_varchar`;
`customer_entity`;
`customer_entity_datetime`;
`customer_entity_decimal`;
`customer_entity_int`;
`customer_entity_text`;
`customer_entity_varchar`;
`customer_grid_flat`;
`customer_log`;
`customer_log`;
`customer_visitor`;

Just run query ONLY - which table has email address field.

1
  • What about if there is another tables stored same data for deleted customers?
    – MagEGY
    Commented Sep 28, 2018 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.