The table name is specified twice as a target for the update, as well as for a separate data source

Update table 
Set class = 0 
Where TOTAL_HOURS = (SELECT min (TOTAL_HOURS) from tutions);

Error generated:

The name of the table, specified twice as both the target for the update and a separate data source.

How can i fix this?

+4
source share
1 answer

I assume that you are trying to update tutions using tutions.

Create a nested subquery so that MySQL materializes it and is no longer the same table.

Try the following:

Update tutions
Set class = 0 
Where TOTAL_HOURS = (select * from (SELECT min (TOTAL_HOURS) from tutions) t);
+5
source

Source: https://habr.com/ru/post/1673825/


All Articles