Multi-table DELETE

suggest change

MySQL lets you name which tables lose rows. A multi-table DELETE cannot use ORDER BY or LIMIT.

-- remove only the employees
DELETE e
FROM Employees e JOIN Department d ON e.department_id = d.department_id
WHERE d.name = 'Sales'
-- remove employees and department
DELETE e, d
FROM Employees e JOIN Department d ON e.department_id = d.department_id
WHERE d.name = 'Sales'
-- remove from all tables (in this case same as previous)
DELETE
FROM Employees e JOIN Department d ON e.department_id = d.department_id
WHERE d.name = 'Sales'

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents