1、删除表中的数据,第一次写如下:
[SQL]delete from yizhu_zhixing_plan_expire
where plan_id in (
select t.plan_id from yizhu_zhixing_plan_expire t
where yizhu_plan_date>=date_format(now() ,'%Y-%m-%d')
and EXISTS (select 1 from yizhu_basic_info a where a.zuhao_id=t.zuhao_id and a.yizhu_State='开始执行' -- and a.type='长期'
)
)
[Err] 1093 - You can't specify target table 'yizhu_zhixing_plan_expire' for update in FROM clause
报错如上:
2、修改脚本后,执行成功了
[SQL]delete from yizhu_zhixing_plan_expire
where plan_id in (
select m.plan_id from (
select t.*from yizhu_zhixing_plan_expire t
where yizhu_plan_date>=date_format(now() ,'%Y-%m-%d')
and EXISTS (select 1 from yizhu_basic_info a where a.zuhao_id=t.zuhao_id and a.yizhu_State='开始执行'
) ) m
)
受影响的行: 0
时间: 2.008s
这个是为啥呢?求指导1