in simple I try do that in PhpMyAdmin:
update wp_postmeta.meta_value = wp_posts.id where
wp_posts.post_name=articles.image
AND wp_posts.post_type=attachment
AND wp_postmeta.meta_key=_thumbnail_id
by this MySQL query:
update wp_postmeta m
join articles a on (m.post_id = a.id)
join wp_posts p on (m.post_id = p.ID)
set m.meta_value = p.ID
where p.post_name=a.image
AND a.image != NULL
AND p.post_type='attachment'
AND m.meta_key='_thumbnail_id'
it’s work but 0 rows affected!
anyone can help?
Use subqueries with Andomar’s answer. Using joins with update and delete statements is not good.
It should be something like
BACKUP FIRST! I didn’t test this.
If doesn’t work try to execute a select query if you can select them. If it doesn’t select (and probably it won’t) please check the structure of your query corresponding to your design.
Also try your first query too
Try to play with/modify the select queries to find out the problem.