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
  • 448
  • 2
  • 6
  • 23

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,541
  • 13
  • 48
  • 65