I have a problem with updating my table with a select from another table. Here is my description:
Table part has the following fields:
part_num PK
active
notes
weight
Table importedDocument has the following fields:
part_num PK
active
notes
weight
quantity PK
condition_id PK
part_num in part is unique, but part_num in importedDocument is not. Every part_num that is in importedDocument is also in part. What I want to do is to get DISTINCT part_num from importedDocuemnt, and with this result I want to update active, notes and weight in part for all the part_num that are in importedDocument.
So far I have this:
UPDATE part
SET
active = importedDocument.active,
notes = importedDocument.notes,
weight = importedDocument.weight,
condition_id = importedDocument.condition_id
FROM importedDocument
WHERE part.part_num IN (SELECT part_num from importedDocument);
I dont understand why the same notes and condition_id is set for all parts from importedDocument.