Hmmm. If you’re using MySQL 4.x you can do fulltext searches in SQL. I’ve not played with the PM database much, but to select all records with a certain string in the body field of pm_comment you’d use:
SELECT * FROM pm_comment where MATCH(body) AGAINST(‘some string’);
NOTE: you will need to add a fulltext index to the body column of pm_comment. By default, this only works on strings 4 chars or more. And MySQL will treat any query where the result set is more than half of the total record count as if it returned an empty set. Read http://dev.mysql.com/doc/mysql/en/Fulltext_Search.html for more information on fulltext search in MySQL.
Also, since there are 2 foreign keys in pm_comment, deleting records will nilly might screw things up