Drupal 7: delete orphaned comment data
Submitted by Erik Wegner on Sat, 11/10/2012 - 15:17
These commands will delete records from the tables field_data_comment_body and field_data_revision_comment_body, so be advised to make a backup first!
DELETE t1.* FROM field_data_comment_body t1 LEFT JOIN comment t2 ON t1.entity_id = t2.cid WHERE t2.cid IS NULL DELETE t1.* FROM field_revision_comment_body t1 LEFT JOIN comment t2 ON t1.entity_id = t2.cid WHERE t2.cid IS NULL OPTIMIZE TABLE `field_data_comment_body` , `field_revision_comment_body`