MySQL: Delete Range of Products from Category

Ask the community for help and support.
Post Reply
lecarlb
VIP Member
VIP Member
Posts: 304
Joined: Mon Oct 26, 2020 5:26 pm
Has thanked: 42 times
Been thanked: 9 times

MySQL: Delete Range of Products from Category

Post by lecarlb »

How do I delete a range of duplicate products from categories using a MySQL query? For example, Category 1 has 1000 products that are already in their rightful place.

Thank you.
burt
Lead Developer
Lead Developer
Posts: 2423
Joined: Tue Oct 29, 2019 9:37 am
Has thanked: 49 times
Been thanked: 137 times

Re: MySQL: Delete Range of Products from Category

Post by burt »

I would do that via the admin page categories.php to ensure that you only delete those products that need deleting. Alternatively if you have a list of product_id you could delete directly from the relevant tables in phpmyadmin (untested [so make a backup] and obviously change X, Y, Z to the list of product_id you have);

delete from products where products_id in (X, Y, Z);
delete from products_description where products_id in (X, Y, Z);

same for other tables such as products_to_categories, reviews etc etc
Gamechanger Addon: Queued Emails, try before you buy.
Post Reply