This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSERT INTO wp_postmeta (post_id, meta_key, meta_value) | |
SELECT ID, '_thumbnail_id', substr(post_content, locate('wp-image-', post_content) + 9, 4) FROM wp_posts AS p | |
LEFT JOIN (SELECT * FROM wp_postmeta WHERE meta_key = '_thumbnail_id') AS m ON p.ID = m.post_id | |
WHERE p.post_type = 'post' AND p.post_status = 'publish' AND left(p.post_content, 100) LIKE '%wp-image-%' AND | |
meta_value IS NULL; |