Update meta_value for specific word

ron9 :

Tabe I am using is wp_post_meta. It has Id, Meta_key and Meta_value column

I am trying to make an update for all links that are in the meta value where meta_key = description.

I have links in meta_value for ex: "https://test.com/today/11am/" needs to be changed to https://www.test.com/today/11am/

Links are dynamic, but all links that starts with https://test.com/ need to be changed to https://www.test.com/

Besides links in the column, there is another text.

Not sure if this is possible to do through a query, if yes please help somehow.

Gordon Linoff :

all links that starts with https://test.com/ need to be changed to https://www.test.com/

In an update you can do:

update t
    set meta_value = concat('https://www.test.com/', substring(meta_value, 17))
    where meta_value like 'https://test.com/%';

Note: You might want some condition on the meta_key as well.

Assuming // occurs only once in the string (reasonable for a URL), you could simplify this to:

update t
    set meta_value = replace(meta_value, '//', '//www.')
    where meta_value like 'https://test.com/%';

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Update product price if specific meta_key contains a specific meta_value

Specific SQL query (multiple meta_value / same row)

How to update meta_value to wp_postmeta

Update meta_value in wp_postmeta from an API response

Get all products with specific meta_key whose meta_value is equal in WooCommerce

Update table wp_postmeta column meta_value where meta_key column equals certain value

How to replace link to specific file type in wordpress database in meta_value?

Update a specific column with a specific value

Update specific value in structure

Update specific value in Realm

get value after specific word

update JsObject value for a specific key

How to Update specific value in UserDefault

Update specific value in JSON file

Update specific value of object in localStorage

Update specific value in array mongoose

not allowing to update value for a specific index

Update the value of a specific field in solr

Python: Replace a specific word in value of dictionary

how to replace a value under specific word in python?

I need to get the value after specific word

How to update an Enum value except of a specific value

update specific cell value when specific cell value is changed

How to update/concatenate specific value in excel cell?

Laravel update a column to a specific value for ALL users

Pymongo How to update specific value of row in array

Update specific state with given key and value?

Update specific column based on other column value

MYSQL Update all values with the value of an specific row

TOP Ranking

HotTag

Archive