Skip to main content

Drupal SQL Query Snippet: Move taxonomy terms from one or more vocabularies into another vocabulary

How do I move Drupal taxonomy terms from one vocabulary to another?

While you can use the excellent Taxonomy Manager module to move taxonomy terms between vocabularies, it's not always worth the trouble to install yet another module. For example, if you are doing this as a one-time merge of several vocabularies into a new vocabulary.

Here's the recipe:

  1. Identify the vocabulary ids (vid) for the source vocabularies. In our example, the source vocabulary ids are 6, 7, 8, and 9.
  2. Identify the vocabulary id for the target vocabulary. In our example, the target vocabulary id is 5.
  3. Execute the following SQL query:
    UPDATE term_data SET vid = 5 WHERE vid IN(6,7,8,9)

How would you do this in Drupal 7

HI How would you do this in Drupal 7 without losing the node associations to these terms?

I tried doing this using Taxonomy Manger and did loose the associations.