Replacing value in sql?

I have a column with values like this: "Here"

I want to change the "web1.expandetunegocio" to "ce.expandetunegocio" so just change web1 to ce

i have tried this query, but dont works:

UPDATE 25v5U995_usermeta
SET meta_value = REPLACE(meta_value, 'web1', 'ce')
WHERE meta_key LIKE '%web1%'

Upvotes: 1

Views: 74

Answers (2)

José Manuel
José Manuel

Reputation: 35

Maybe this can help you https://www.w3schools.com/sql/sql_update.asp

I think your problem is that 'WHERE meta_key LIKE '%web1%'' don't get any result. Can you try to do a select?

 SELECT * FROM '25v5U995_usermeta' WHERE meta_key LIKE '%web1%' 

Upvotes: 0

Sam
Sam

Reputation: 522

All you need to do is use the right column in your WHERE condition

The following query should work in your case:

UPDATE 25v5U995_usermeta SET meta_value = REPLACE(meta_value, 'web1', 'ce') WHERE meta_value LIKE '%web1%'

Since the web1 substring exists in meta_value column, instead of meta_key column hence was unable to find the right row.

Upvotes: 3

Related Questions