If we want to set employeeCode in employeeMaster1 from employeeMaster2 for corresponding employeeId
A join:
UPDATE employeeMaster1 AS t1
INNER JOIN employeeMaster2 AS t2 ON t1.employeeId = t2.employeeId
SET t1.employeeCode = t2.employeeCode
By Using left join:
UPDATE employeeMaster1 AS t1
LEFT JOIN employeeMaster2 AS t2 ON t1.employeeId = t2.employeeId
SET t1.employeeCode = t2.employeeCode
A subquery:
UPDATE employeeMaster1
SET employeeCode = (
SELECT employeeCode
FROM employeeMaster2
WHERE employeeId = employeeMaster1.employeeId
)
No comments:
Post a Comment