0

I want to update Table 1 by taking the value from Table 2. Both the tables have Emp No which is a key. I want to update the Salary column in Table 1 with the value that is present in Table 2

UPDATE TEST.tbl1  --< first the table that will be updated
JOIN   TEST.tbl2
ON     tbl1.IDNo = tbl2.IDNo
SET    Salary = Salary (From Second Table)

When i tried this iam getting an Error.. It says Error at or before the TEST..

Please anyone help me

4
  • Specify what table the field is taken from for all fields: Set TEST.tbl1.Salary = TEST.tbl2.Salary. And remember - if more than one record in tbl2 matches to a record from tbl1 than a random record will be used for updating.
    – Akina
    Dec 13, 2018 at 6:38
  • It says Error at or before the TEST Is TEST the name of your database? if not remove 'TEST.' substrings.
    – Akina
    Dec 13, 2018 at 7:17
  • TEST ---Is the name of the region of my Database (eq Test, Prod, INTG)
    – user166993
    Dec 13, 2018 at 7:39
  • Database region? What's that? Server-Database-Table-Record-Field, that's all.
    – Akina
    Dec 13, 2018 at 8:04

1 Answer 1

0
UPDATE tbl1, tbl2
SET tbl1.Salary = tbl2.Salary
WHERE tbl1.IDNo = tbl2.IDNo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.