I was trying to Update a query on MS-Access. Let's Assume, I have two Tables (Employee, Department
). I have (ID, Name, FK_DepartmentID
) in Employee
Table. And, two Column in Department
(ID, DepartmentName
) Table, Where I want to check if department Name exists in Department
Table, then Update in Employee.FK_DepartmentID
, else Null. Currently, I am updating with
UPDATE Employee, Department SET
Employee.Name = 'David',
Employee.FK_DepartmentID = Department.ID
WHERE (((Employee.ID)='55') AND ((Department.DepartmentName)='HR');
So this is updating my Employee
Table. But Let's say User input Department.DepartmentName='IT'
, where 'IT' doesn't exist in Department
Table (Or User input nothing). With the current query, it executes but doesn't update any row. But I want it to update Employee.Name
alongside Employee.DepartmentID = Null
. What can I do so I can reach what I want.
Really appreciate your time and thanks in advance.