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

旧时模样 提交于 2021-02-07 06:17:05

问题


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?


回答1:


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);


来源:https://stackoverflow.com/questions/43171583/table-name-specified-twice-both-as-a-target-for-update-and-separate-source-for-d

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!