On my wordpress I have a little over 1000 posts which I’m looking to update a certain meta_vale of a particular meta_key and was wondering how I can do this with mysql. The meta_key I need to update is “Crafting” and I want to update every meta_value that currently has 40 / 400 (Golden) to just 400. “Crafting” has other values so I only want to update the ones that have the 40 / 400 (Golden) meta_value to 400.
What I’ve found so far but need some help finishing the query.
REPLACE INTO `wp_postmeta` (
`meta_id`
, `post_id`
, `meta_key`
, `meta_value`
)
SELECT
`meta_id`
, `post_id`
, "Crafting"
, "40 / 400 (Golden)" -- assuming all posts to be set the same
After this I’m not really sure how what to.
Assuming I’m understanding your question, you want to update the
meta_value
field to400
in all posts that havemeta_key = 'crafting'
andmeta_value = '40 / 400 (Golden)'
?If so, a simple
Update
statement will work: