During the years, syncing with other tools who sometimes have "space" between tags (but where you use commas) i build up a collection of tags who have commas in them.
I can not simply replace them in the database because at the same time the tag WITHOUT comma is used. So the related posts with comma tag should move to the posts without comma tag and only then remove the tag.
Before I code this, has anyone this piece of code?
So for each of these terms I will have to
1) find the corresponding tag without a comma
1a) if it exists temporarily store it
1b) if it does not exist then simply rename the name and slug and go to the next tag
2) find the entries in the wp_term_taxonomy table and count the references and the key
3) use this key to find the entries in the wp_term_relationships table
4) link them to the stored tag without a comma (in other words replace the term_taxonomy_id in wp_term_relationships)
5) and then remove the tag in the wp_terms and wp_term_tanxomy table
This loop would do it.
(and since it are a LOT of tags I dont want to merge them manually)