I am trying to map a contributor_id
in my archive
table to a contributor_id
in my sales
table. The archive
table has 120k entries and the sales
table has 20k. The sales
table has an 'uploaded_filename' field, as does the archive
table.
The sales
table's uploaded_filename
s are often repeated multiple times in the archive
table.
My question is how do I write a query that maps the contributor_id
in the archive
to the corresponding uploaded_filename
Table Design (I'm omitting extraneous fields)
Archive:
| uploaded_filename | contributor_id |
Sales (at present):
| uploaded_filename |
My attempt:
UPDATE sales
SET contributor_id = a.contributor_id
FROM sales s
INNER JOIN archive a
ON a.uploaded_filename = s.uploaded_filename;