I am doing an update for our database and want to update rows that do not have existing elements in another table. I can join the tables together, but I had problems with grouping the table to get a count of the number of rows
UPDATE dpt SET dpt.active = 0 FROM DEPARTMENT dpt LEFT JOIN DOCUMENTS doc on dpt.ID = doc.DepartmentID GROUP BY dpt.ID HAVING COUNT(doc.ID) = 0
What should I do?
source share