I’ve imported 1 xlsx file and its 2 sheets as tables into Libreoffice Base. These are: membership and contract. Membership contains a list of membership id-s (not auto incremented and this column is the primary key), workers, status, contract begins, contract ends. There are duplicates among workers, because some of them have multiple contracts and therefore multiple membership id-s. And there is the contract table: it containcs the contract (primary key), worker (again duplicates), status, contract begins, contract ends, membership id. Some of the membership ids are missing, I should update them from the other table.
This is the best I’ve come up with so far:
UPDATE “contract”
SET “contract”.“membership_id” = (select “membership”.“id” FROM “membership” WHERE “worker” = “contract”.“worker”)
WHERE “contract”.“membership_id” IS NULL
When I run this, not a single value is updated. I guess the reason why I keep failing is the presence of duplicates. I have no idea how to find the correct values for membership id. A worker can have multiple contracts, the only way i can tell them apart is the use of contract begins and contract ends columns (both tables contain these info). But again, some values are missing there. I have no idea how to start. Hopefully I was able to explain it well enough.