now I try this query in PhpMyAdmin to update wp_postmeta with value form wp_posts:
UPDATE wp_postmeta
SET meta_value = (SELECT DISTINCT id FROM wp_posts)
WHERE EXISTS (select 1
from wp_posts
join articles on wp_posts.post_name=articles.image)
AND (wp_posts.post_type='attachment')
AND (wp_postmeta.meta_key='_thumbnail_id' )
but given me that error: #1054 – Unknown column ‘wp_posts.post_type’ in ‘where clause’ !
i try to change it without benefit, anyone can help?
I think the real issue here, is that the only place you’re referencing wp_posts is in your EXISTS and SET subqueries. That part of the WHERE clause (quoted above) is outside the scope of your subqueries and doesn’t know about it.
Unless you meant for your EXISTS subquery to look like this:
In this case, wp_posts is referenced in the same set of parens and is syntactically correct. Since this probably won’t give you what you’re after, try this instead:
Note #1: I’m making an assumption that your wp_postmeta table has a post_id field that corresponds to id on wp_posts.
Note #2: As OMG Ponies stated…
This line will most-likely throw an error for returning multiple values where only 1 is expected. Note that I’ve added a “WHERE [some condition]” above. You’ll want to add your own WHERE clause here. And it should be something that limits the subquery result to only one result.
You should move your right parenthesis in:
to the end of the statement.