rfresh
07-24-2011, 12:52 AM
I have the following SELECT query statement which works fine. What I want to do now is turn it into a DELETE statement. But when I replace SELECT with DELETE, I get an error. I've tried removing the DISTINCT but I still can't get it to delete.
Thanks for any help.
SELECT DISTINCT E.*, COUNT(ED.id) AS dcnt FROM Employees E LEFT JOIN EmpDepts ED ON E.id = ED.emp_id WHERE E.company_index = 78 AND E.employee = 0 GROUP BY E.last_name HAVING dcnt = 0
Thanks for any help.
SELECT DISTINCT E.*, COUNT(ED.id) AS dcnt FROM Employees E LEFT JOIN EmpDepts ED ON E.id = ED.emp_id WHERE E.company_index = 78 AND E.employee = 0 GROUP BY E.last_name HAVING dcnt = 0