I have 2 related tables called tblResponse and tblUser, I want to delete records from tblUser which have a value of inactive in the status column.
In the tblResponse table, I also want to delete all these records whose UserId from tblUser have been deleted.
Each UserId potentially has multiple responses in tblResponse table, it needs to delete all of them.
This jobs needs to run everyday.
DELETE A
FROM tblUser A
INNER JOIN tblUser U ON UserId = EmployeeID
WHERE UserStatus = 'Inactive'
In the above query UserId is from tblUser and EmployeeID is from tblResponse.
How can I delete the data from 2 tables ?