mysql 遇到的问题
1.You can’t specify target table ‘*****’ for update in FROM clause
大致意思是不能用对查询的表做修改操作
## 错误语句
update storeproducts set max_stock_quantity = 0 where id in(
select sp.id from storeproducts sp
left join products p on sp.product_id = p.id
where p.name like "%供应链自动化商品%");
## 用一张临时结果表作为中间表,不直接修改查询表的数据,而是修改中间表的数据
update storeproducts set max_stock_quantity = 0 where id in(
select tmp.id from ( ## 查询的结果存放在中间表
select sp.id from storeproducts sp
left join products p on sp.product_id = p.id
where p.name like "%供应链自动化商品%")as tmp);