postgresql update join subquery