I have having problems updating one table from another. I want SQL to update the rows in Employees
from the data in CompanyEmployees
where the two EmployeeNum
fields are the same. Also if an EmployeeNum
exists inside of CompanyEmployees
that doesn't match one in Employees
then I need a new row created in Employees
I so far have tried a join for the two tables.
SELECT Employees.PhoneNum, Employees.Data,
CompanyEmployees.PhoneNum, CompanyEmployees.SystemData
FROM CompanyEmployees
INNER JOIN Employees
ON CompanyEmployees.Employees=Techs.EmployeeNum
I get the right column data in both tables but i doesnt update Employees
. Do I need an INSERT or UPDATE somewhere?
How can I insert the whole row of data from CompanyEmployees
into Employees
where CompanyEmployees.EmployeeNum
doesn't exist in Employees
?
I need to do this because CompanyEmployees
is only a phone directory and Employees
has phone numbers and more information. But CompanyEmployees
has new hires inside it that are not inside Employees
.