How is a table locked regarding UPDATE-SELECT queries in PostgreSQL? Is it possible to combine these UPDATE queries?

UPDATE myTable1 SET fld1 = myTable2.value
FROM myTable2
WHERE myTable1.id = myTable2.id AND myTable2.style = 45;
UPDATE myTable1 SET fld2 = myTable2.value
FROM myTable2
WHERE myTable1.id = myTable2.id AND myTable2.style = 46;
UPDATE myTable1 SET fld3 = myTable2.value
FROM myTable2
WHERE myTable1.id = myTable2.id AND myTable2.style = 47;


And also, how is the lock on these two tables?
The question about locks was addressed by a_horse_with_no_name in the comments to the question:


  an UPDATE will never lock a table - it will only lock the rows that have been updated (in the target table). A select never locks any rows


And as for combining the three update statements into one, yes, it is possible, though not necessarily a good idea. Still, if you insist, here is one way:

UPDATE
  myTable1
SET
  fld1 = CASE myTable2.style WHEN 45 THEN myTable2.value ELSE myTable1.fld1 END,
  fld2 = CASE myTable2.style WHEN 46 THEN myTable2.value ELSE myTable1.fld2 END,
  fld3 = CASE myTable2.style WHEN 47 THEN myTable2.value ELSE myTable1.fld3 END
FROM
  myTable2
WHERE
  myTable1.id = myTable2.id
  AND myTable2.style IN (45, 46, 47)
;


Basically, you do the join, combine the three filter conditions with an IN predicate and in in each of the three assignments you use a CASE expression to check if the myTable2.style value matches a corresponding value from the filter, so that you can decide whether to assign the myTable2.value to the column (THEN branch) or keep the old value (ELSE branch).

Your three separate statements look clearer/more readable to me, though.