2

I'm trying to update a tablecolumn based on another value inside this table but I keep getting an error.

My query is as follows:

    UPDATE partcreditor 
    SET partcreditor.creditorid = creditor.creditorid
    FROM partcreditor
    INNER JOIN creditor ON partcreditor.creditornr = creditor.creditornr
    WHERE creditor.relgroupid = 1
    AND creditor.creditortypeid = 1
Bart
  • 565
  • 2
  • 7
  • 24

1 Answers1

2
UPDATE partcreditor AS PC
INNER JOIN creditor AS CR ON PC.creditornr = CR.creditornr
SET PC.creditorid = CR.creditorid
WHERE CR.relgroupid = 1 AND CR.creditortypeid = 1

No need to use the FROM clause in the update. As well as use alias name for better readability.

Arulkumar
  • 12,966
  • 14
  • 47
  • 68