I wanted to split my blog into a techie and non-techie set of content. I created a new set of hierarchical categories that suited the purpose and was left with a problem. I didn’t want to go through all of the old posts and put them into the relevant category. So I did this:
mysql> insert into term_node (nid,tid)
mysql> select nid,status from node where type=”blog”;
This created an entry in the term_node table for every blog entry that was published. The tid or category identifier was set to 1 which didn’t match the number I wanted from the term_data table:
mysql> select * from term_data;
So I did this:
mysql> update term_node set tid=3 where tid=1;
That set everything to the category I wanted (non-techie).
But I had inadvertantly created duplicates because I’d used the INSERT command instead of the UPDATE command. Luckily the duplicates all had a tid of “0” (this must have been due to a previous drupal version automatically creating entries in the table as it only happened for a set of approximately 30 nodes that would have been created in the middle of last year). So I was able to:
mysql> delete from term_node where tid=”0″;
Sorted. Now all I’ve done is gone through the last 10 posts by hand and moved the techie posts into the correct category. I’m not worried about posts prior to that.
Oh and I did mysqldump the database before I started!!