Mysql
 sql >> Database >  >> RDS >> Mysql

Elimina utilizzando più tabelle e ripeti la tabella nella sottoquery

Usa un JOIN

DELETE e1
FROM Employee AS e1
JOIN (SELECT deptID
      FROM Employee AS e
      JOIN Sales AS s ON e.ID = s.ID
      GROUP BY deptID
      HAVING SUM(Sales) <= 400) AS d
ON e1.deptID = d.deptID