iks_in iks_in - 1 year ago 64
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?

Answer Source

No need to use a sub-query:

Update tableA
set email= replace(email,'www.','') 
WHERE email like "www%" and email like "%@%" and website=""
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download