Achilles Achilles -5 years ago 357
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 .

Answer Source

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 =;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download