iks_in
iks_in

Reputation: 133

Update query with replaced values

I want to update a table with replaced values of a specific field in MySQL. Below is my query.

Update tableA
set email=(SELECT replace(email,'www.','') FROM tableA WHERE email like "www%" and 
email like "%@%" and website="")  

But it gives me an error that

You can't specify target table for update in from clause

I've tried using inner join but getting the same error again and again. Please guide me where am I mistaking?

Upvotes: 1

Views: 41

Answers (1)

jarlh
jarlh

Reputation: 44766

No need to use a sub-query:

Update tableA
set email= replace(email,'www.','') 
WHERE email like "www%" and email like "%@%" and website=""

Upvotes: 2

Related Questions