Rudra Upadhyay
Rudra Upadhyay

Reputation: 81

Table name specified twice both as a target for update and separate source for data

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

Produced Error:

Table name specified twice both as a target for update and separate source for data.

How can I fix this?

Upvotes: 8

Views: 13583

Answers (1)

Gurwinder Singh
Gurwinder Singh

Reputation: 39477

I am guessing you are trying to update tutions with tutions.

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

Try this:

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

Upvotes: 13

Related Questions