iks_in iks_in - 6 months ago 17
SQL Question

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?


No need to use a sub-query:

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