UPDATE wp_posts AS p1 JOIN wp_posts AS p2 ON p1.post_parent = p2.ID SET p1.post_excerpt = p2.post_title WHERE p1.post_type = 'attachment' AND p1.post_excerpt = '';