Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Excluir usando várias tabelas e repetir a tabela na subconsulta


Use um 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