Jump to content

Bulk delete empty categories from DB


bibob

Recommended Posts

Found a solution

 

DELETE FROM`ps_category`  WHERE   `id_category` != 1   and  id_category not in    (SELECT cp.id_category from  ps_category_product cp ) ;
DELETE FROM `ps_category_lang` where id_category not in (select id_category from ps_category);
DELETE FROM `ps_category_group` where id_category not in (select id_category from ps_category);
DELETE FROM `ps_category_shop` where id_category not in (select id_category from ps_category);
  • Like 1
  • Haha 1
Link to comment
Share on other sites

  • 5 months later...

This is excellent

 

Was successful

 

Thankful   :) 

 

 

Found a solution

 

DELETE FROM`ps_category`  WHERE   `id_category` != 1   and  id_category not in    (SELECT cp.id_category from  ps_category_product cp ) ;
DELETE FROM `ps_category_lang` where id_category not in (select id_category from ps_category);
DELETE FROM `ps_category_group` where id_category not in (select id_category from ps_category);
DELETE FROM `ps_category_shop` where id_category not in (select id_category from ps_category);

 

Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...
  • 1 year later...
On 4/21/2020 at 12:11 AM, Gipielle said:

Hello, this query is for all prestashop versions ?

I ps 1.7 replace ps_ by miib_

 

DELETE FROM`miib_category`  WHERE   `id_category` != 1   and  id_category not in    (SELECT cp.id_category from  miib_category_product cp ) ;
DELETE FROM `miib_category_lang` where id_category not in (select id_category from miib_category);
DELETE FROM `miib_category_group` where id_category not in (select id_category from miib_category);
DELETE FROM `miib_category_shop` where id_category not in (select id_category from miib_category);

 

Edited by jmauclair (see edit history)
  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...