Rakesh Kaushik

Rakesh Kaushik

  • NA
  • 56
  • 35.6k

comparision of two table and insert records to 2nd table

Mar 15 2013 5:32 AM
Hello Guys,
I have two tables First One is.
**tblSalaryMaster**(salaryID,salaryName)
records are
salaryID salaryName
 1          Basic
 2          HRA
 3          Ca
and 2nd is **tblSalaryDetailMaster**(companyID,employeeID,salaryID,salaryAmount)
records are
companyID employeeID salaryID salaryAmount
1            1          1           10000
1            1          2            5000
1            1          3            2000
1            2          1           15000
1            2          2            6000
1            2          3            3000
1            3          1           12000
1            3          2            4000
1            3          3            1000
and so on
now i add one more record to First Table **tblSalaryMaster**
now records are
salaryID salaryName
 1          Basic
 2          HRA
 3          Ca
 4          Allowance
now i want to loop through first table (salaryID)records and search the records in 2nd table
and if second table don't have the records(salaryID) matched with 2nd table then insert the record into
second table with companyid and employeed supplied with.
Please help me.

Answers (1)