0

I have two tables tblemployee, tblEmpSalary. I want to take the MonthlySalary form the tblEmployee and multiply it with the attendance in the tblEmpSalary and insert the answer to the tblEmpSalary table totalsalary column. Anyone kindly help me please.

tblEmployee
>EmpId
>Empname
>MonthlySalary

tblEmpSalary
>SalaryId
>EmpId
>Month
>Year
>AttendanceOfCurrentMonth
>TotalSalaryOfMonth

I want the TotalSalaryOfMonth to be the

multiplication of MonthlySalary and AttendanceOfCurrentMonth

for each specific employee

2 Answers2

1

Try this

UPDATE tblEmpSalary set TotalSalaryOfMonth=e.MonthlySalary*s.AttendanceOfCurrentMonth
from tblEmployee e join tblEmpSalary s ON e.empId=s.empId
1

I think you are looking for Update based on Join conditions. This link already answers your question.

UPDATE A SET TotalSalaryOfMonth = AttendanceOfCurrentMonth * MonthlySalary FROM tblEmpSalary A INNER JOIN tblEmployee B ON A.EmpId = B.EmpId

Community
  • 1
  • 1