Achilles Achilles - 4 months ago 27
MySQL Question

Error Code: 1093. Table 'site_html' is specified twice, both as a target for 'UPDATE' and as a separate source for data

I want to update the 'status' column of the table with respective id , but it leads me to error code 1093.
Below is my SQL Query

Update site_html Set status='Update Found'
Where id = (
select id
from site_html
where link='');

How can i correct this error? I am new to SQL .


In MySQL, you can't modify the same table name directly which you use in the SELECT part. So you can do it through table alias.

update site_html AS s, (select id  from site_html where link='') AS t
set status='Update Found' 
where =;