MySQL: Delete Range of Products from Category

Open to all! Ask other shopowners for help.
Post Reply
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 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.


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 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
I am not here to build for you.
I am here to build with you. Let's help each other.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply