ex employees in dropdown lists
We have a contracts system that incorporates dropdown lists of employees, some of which have left the company. We would like to remove the ex employees from the list which is easy enough however on some of the forms the ex employees have been selected. Obviously until someone goes into the开发者_开发知识库 form and updates to a current employee we do not want the ex employee to dissapear.
Basically i would like them to appear in the list if chosen otherwise i would like them not to appear. Any ideas on the best way to handle this?
One idea that comes to mind would be to make a fake current employee. Then, you can transfer all ex-employee entries to this new fake employee. This will let you get rid of the ex-employees while still keeping those contracts from dissapearing.
Assuming that there are two tables: One with a full list of employees, containing the employees you want to delete (Employees) and another with a list of contracts that could contain these employee numbers (Contracts), and also making assumptions about the table structure, and assuming that the drop-downs are driven from these tables, this is how I'd go about it:
SELECT EmployeeNumber, EmployeeName From Employees WHERE Terminated = 1
AND NOT (EmployeeNumber IN (Select EmployeeNumber FROM Contracts))
Of course, there are a lot of assumptions to this answer. I'm just going off best guesses based on the info provided.
Add a column to the employee table that lists whether they're still employed, and use this field in queries where you want to include/exclude employees on the basis of their current employment status.
精彩评论