Gossamer Forum
Home : Products : Gossamer Links : Discussions :

How do I delete multiple categories?

Quote Reply
How do I delete multiple categories?
I have a rather large database and I am wanting to trim it.

When I use the plugin find multiple categories, I show that I have close to 1000 categories with 0 links

Is there a way to delete them all at once? Is there any type of plugin for that?

Also I need to be careful not to delete a category that has sub categories with links.

Thanks
Quote Reply
Re: [palehorse1677] How do I delete multiple categories? In reply to
SELECT * FROM lsql_Category WHERE Number_of_Links="0";

This command "finds" all of them, but if I replace SELECT with DELETE will I hurt the database?
Quote Reply
Re: [palehorse1677] How do I delete multiple categories? In reply to
No, do not perform operations like that on links' tables, as you'll likely delete categories that have subcategories as well as ruining the Category_tree table.

You should be going through the categories to make sure they should be deleted and delete them through the admin (or write some code to delete them).

Adrian
Quote Reply
Re: [brewt] How do I delete multiple categories? In reply to
Is there an easy way to do that, or do you need to select out categories that have 0 links, then delete them one by one if a select Father_ID = Category_ID returns no hits?

If no other category has that Father_ID, then there are no children.

The best way would probably be to recursively walk the tree and check each leaf node on the way OUT if it has any links or subcats. If not, then delete.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.