DELETE FROM table_name WHERE column1 IN (SELECT column1 FROM table_name GROUP BY column1 HAVING COUNT(*) > 1); 这里要注意会报错You can‘t specify target table for update in FROM clause 只需要在SELECT column1 FROM table_name GROUP BY column1 HAVING COUNT(*) > 1 套个子查询就可以了 select a.column1 from (SELECT column1 FROM table_name GROUP BY column1 HAVING COUNT(*) > 1) a
select inventory_order,lot_code from inventory_check_detail 37000
select DISTINCT inventory_order,lot_code,loc_code,qty from inventory_check_detail 36779
delete from inventory_check_detail where id in ( (select a.id from (select id from inventory_check_detail GROUP BY inventory_order,lot_code,loc_code,qty HAVING count(*) >1) a);
select * from inventory_check_detail where id in (select a.id from (select id from inventory_check_detail GROUP BY inventory_order,lot_code,loc_code,qty HAVING count(*) >1) a)
select * from inventory_check_detail where inventory_order='IC20231027-0015' and lot_code='ZD230819039#001'
select a.id from (select id from inventory_check_detail GROUP BY inventory_order,lot_code,loc_code,qty HAVING count(*) >1) a
select id from inventory_check_detail GROUP BY inventory_order,lot_code,loc_code,qty HAVING count(*) >1