码迷,mamicode.com
首页 > 其他好文 > 详细

ERROR 1093 (HY000): You can't specify target table 'bm_area' for update in FROM clause

时间:2015-07-22 10:58:51      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:linux

开发执行时出现错误:

update bm_area  set level = 2 where parent_code in (select b.parent_code from bm_area as b where b.level = 1);

ERROR 1093 (HY000): You can‘t specify target table ‘bm_area‘ for update in FROM clause



一般使用:

create table tmp as select b.parent_code from bm_area as b where b.level = 1;


update bm_area  set level = 2 where parent_code in (select parent_code from tmp);



两条合成一条

update bm_area  set level = 2 where parent_code in (select parent_code from (select parent_code from bm_area  where level = 1)tmp);


本文出自 “dba天空” 博客,请务必保留此出处http://9425473.blog.51cto.com/9415473/1676995

ERROR 1093 (HY000): You can't specify target table 'bm_area' for update in FROM clause

标签:linux

原文地址:http://9425473.blog.51cto.com/9415473/1676995

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!