首页 > 其他 > 详细

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

时间:2015-07-22 10:56:39      阅读:134      评论:0      收藏:0      [点我收藏+]

开发执行时出现错误:

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!