开发执行时出现错误:

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