0

Since Joomla does not have a tag merging feature, I'm looking for a way to merge existing tags using SQL query in phpmyadmin.

  • Old tag_id=1
  • New tag_id=2

This query works as long as all of the articles that have the tag_id=1 don't have also the tag tag_id=2.

Update xxx_contentitem_tag_map SET tag_id=2 WHERE tag_id=1

But it doesnt work when one of the article also have the tag_id=2. So I'm looking for a smart query that would work only on that selection:

SELECT * FROM xxx_contentitem_tag_map WHERE tag_id=1 AND tag_id!=2

How should I merge this SELECT query with the update query?

1 Answer 1

1

Try this, but please backup your database before:

UPDATE
  xxx_contentitem_tag_map
SET
  tag_id = 2
WHERE
  tag_id = 1 AND 
  core_content_id NOT IN (
    SELECT 
      core_content_id 
    FROM 
      xxx_contentitem_tag_map 
    WHERE
      tag_id = 2
  )

Basically you have to select all article IDs where the tag ID is already 2 and then exclude them from your update query by using the NOT IN operator

1
  • @JinSnow if this answer solved your problem, please award it the green tick. If something is not quite right, please leave a comment under the answer and perhaps update your question with what is left to resolve. Commented Jan 31, 2019 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.