MySQL中 delete from 时提示 1064 错误。

select * from wms_inventory i WHERE not EXISTS (select 1 from wms_item t where t.id=i.SKU_ITEM_ID and t.company_id=i.COMPANY_ID);

select *  from wms_inventory i LEFT JOIN wms_item t on t.id=i.SKU_ITEM_ID and t.company_id=i.COMPANY_ID where t.id is null;

 

delete from wms_inventory i WHERE not EXISTS (select 1 from wms_item t where t.id=i.SKU_ITEM_ID and t.company_id=i.COMPANY_ID);

delete from wms_inventory i LEFT JOIN wms_item t on t.id=i.SKU_ITEM_ID and t.company_id=i.COMPANY_ID where t.id is null;

改为

delete i.* from wms_inventory i WHERE not EXISTS (select 1 from wms_item t where t.id=i.SKU_ITEM_ID and t.company_id=i.COMPANY_ID);

delete i.* from wms_inventory i LEFT JOIN wms_item t on t.id=i.SKU_ITEM_ID and t.company_id=i.COMPANY_ID where t.id is null;

 

原因:因为insert、update、delete都只能针对一个表操作!

上一篇:Linux下批量修改文件名


下一篇:MongoDB 集合间关联查询后通过$filter进行筛选