Reputation: 605
I just want to be sure before I press the button...
I want to do a search and replace. A row has a column meta_key and a column meta_value. The condition is that meta_key has to be product_page and then I want to replace in meta_value is oldtext- with newtext-.
When I just want to a search and replace in one column I can do
UPDATE `wp_postmeta` SET `meta_value` = REPLACE (
`meta_value`,
'oldtext-',
'newtext-');
but where do I put the condition to also check in the meta_key column?
Upvotes: 0
Views: 204
Reputation: 1269883
In the where
clause:
UPDATE `wp_postmeta`
SET `meta_value` = REPLACE(`meta_value`, 'oldtext-', 'newtext-')
WHERE meta_key = 'product_page';
Upvotes: 2