Altering all content under the node_revisions table
When we began using Drupal, it was not with Clean URLs. So at this point all content has ?q= hyperlinks.
I've posted before on this subject and came up with various methods for cleaning this up, and the simplest is using the Replace() function in MySQL.
update node_revisions set body = replace(body, '/?q=', '/');
However this creates an issue with the content:
Before the query I have content such as:
<a href="/?q=linktest">link test</a>and the content shows a hyperlink of /?q=linktest
After I run the query, viewing the node shows the text "link test" with the hyperlink of /linktest. If I edit the same node, the code in the node now shows:
<a href="/?q=linktest">link test</a><a href="/linktest">link test</a>and if I save it, it shows both links when viewing the node. It only gives both /?q and the / link if I edit it and remains with only / if I don't.
This seems like a really odd issue. Does anyone have an idea?

Too add to the illustration,
Too add to the illustration, here is what I find in MySQL after the update query:
mysql> select body from node_revisions where nid = 551;
+--------------------------------------------------------------------------------------+
| body |
+--------------------------------------------------------------------------------------+
| Test Hi <a href="?q=TestHi">Weee</a>
Test Hi with a / <a href="/TestHi">Weee/</a> |
+--------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
Here is what shows in node/551/edit:
Test Hi <a href="?q=TestHi">Weee</a>
Test Hi with a / <a href="/?q=TestHi">Weee/</a>Test Hi <a href="?q=TestHi">Weee</a>
Test Hi with a / <a href="/TestHi">Weee/</a>
Any help is appreciated.
I've now figured out that it
I've now figured out that it had to do with the teaser. I've fixed the issue by replacing text in the teaser and the body.
In case anyone is deciding to follow the same path as me, here are the two queries:
update node_revisions set body = replace(body, '/?q=', '/'), teaser = replace(teaser, '/?q=', '/');
update node_revisions set body = replace(body, '?q=', '/'), teaser = replace(teaser, '?q=', '/');
I first search for /?q= and then ?q=. The reason being that if I just replace ?q=, all links starting with /?q= will become //. There are a mixture of /?q= and ?q= on the site so this takes care of it. Happy day.