+ WHERE tag_id IN (' . implode(',', $ids) . ')
+ AND entry_id NOT IN (
+ SELECT entry_id
+ FROM (SELECT * FROM ' . $this->getTable('entry_tag') . ') AS _entry_tag
+ WHERE tag_id = ' . $newId . '
+ )'
+ );
+
+ // Delete links to unused tags
+ $this->addSql('
+ DELETE FROM ' . $this->getTable('entry_tag') . '
+ WHERE tag_id IN (' . implode(',', $ids) . ')'