Select from one table based on condition in another. Update when same table in Select with additional joins.