I have an anomaly in my database and I need to fix it. Trying to figure out what caused it but in the meantime I need to fix the issue. Have two tables. Person and Employee.
Person has below fields (I'll only use the fields that are important).
Person.Id, Person.FN, Person.LN, Person.SN
Employee has the below fields (I'll only use the fields that are important)
Employee.EmpId, Person.Id, Employee.CID, Employee.FID
The issue is that there are two person records and two employee records.
The two person records are John Doe and have two separate Employee records. So lets say
Person
123, John, Doe, 123456789
234, John, Doe, 123456789
Employee
567, 123, 888, 999
789, 234, NULL, NULL
The issue I have is the nulls. I have approximately 500 records that have this issue.
How can I write an update statement to easily update record Employee.CID, Employee.FID of 789 with the Employee.CID, Employee.FID of 567 for the same person?
Update Employee
Set Employee.CID = (.....),
Employee.FID = (.....)
Thanks