7
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?

Gurwinder Singh
  • 38,557
  • 6
  • 51
  • 76
Rudra Upadhyay
  • 71
  • 1
  • 1
  • 2
  • 2
    is that the real query ? in your query you use table as tablename and table is a keyword. so you must quote it in backticks – Bernd Buffen Apr 02 '17 at 18:04

1 Answers1

12

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);
Gurwinder Singh
  • 38,557
  • 6
  • 51
  • 76