本文主要是介绍You can't specify target table 't_XXX' for update in FROM clause,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中)。
解决方法:select的结果再通过一个中间表select多一次,就可以避免这个错误
delete from t_XXX where f_XXX
in (select b.f_XXX from t_XXX
b WHERE b.f_hold_year=2016 group by b.
f_XXX having count(b.f_XXX) > 1)
处理后
delete from t_XXX where f_event_name
in (
select bb.f_XXX from(
select b.f_XXX from t_XXX b
WHERE b.f_hold_year=2016 group by b.f_XXX
having count(b.f_XXX) > 1) bb
)
这篇关于You can't specify target table 't_XXX' for update in FROM clause的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!