Below you can see my simplified DB model:

Due to an error there are only null-values in the column Job.location where the entries belong to a certain Plan. Therefore I want to update all Jobs associated with this Plan, setting Job.location to Location.name of the User, who owns this Plan.
I tried this SQL query:
update dbo.Job set location =
(select name from dbo.Location as loc where
loc.objectid = objectid and loc.user_id in
(select userid from dbo.[Plan] as p where p.planid = 20))
where planid = 20
However, the result is always: 0 rows affected. The subqueries itself work correctly.
How can I achieve that all Jobs with a certain planid are affected?
I think you mistake may be that you have no alias for
objectidcolumn in subqueryloc.objectid = objectid, so when you running subquery by itself, it just works likeloc.objectid = loc.objectidand when you running it in the update, it works likeloc.objectid = dbo.Job.objectidIn your schema it’s possible to have multiple locations for users, but supposing you have only one location per user and object, you can try this query: