1、 需求ide
要将base_info.name以wl_开头的数据的status字段更新为2优化
2、执行spa
Update base_infoci
Set a.status=2get
Where (select id from base_info where name like ‘%xx%’)it
执行时,提示1093错误,table
ERROR 1093 (HY000): You can't specify target table 't' for update in FROM clause 。class
mysql不支持修改一个表的时候子查询不能是同一个表。date
3、 优化select
经过临时表解决这个问题
方法一:
Update base_info
Set a.status=2
Where id in ( select * from (select id from base_info where name like ‘%xx%’ ) tmp )
方法二:
update base_info b
join (select id from base_info where act_name like 'wlq_%') tmp
on tmp.id= b.id
set b.expand1=2