Mysql
 sql >> Datenbank >  >> RDS >> Mysql

DELETE FROM HAVING COUNT(*) in MySQL

Wie im Handbuch angegeben :

Ich denke, Sie müssen diese Operation über eine temporäre Tabelle ausführen:

CREATE TEMPORARY TABLE temp
  SELECT   part_desc
  FROM     ag_master
  GROUP BY part_desc
  HAVING   COUNT(*) > 1000;

DELETE FROM ag_master WHERE part_desc IN (SELECT part_desc FROM temp);

DROP TEMPORARY TABLE temp;