update mesolduslugacomplex muc
set
    mesolduslugacomplex_enddt = t.mes_enddt,
    pmuser_updid = 1,
    mesolduslugacomplex_upddt = now()
from (
  select
      muc.mesolduslugacomplex_id,mes.mes_enddt
  from mesolduslugacomplex muc
   join v_mesold mes on muc.mes_id = mes.mes_id
  where
      muc.mesolduslugacomplex_enddt is null and mes.mes_enddt is not null
      and mes.region_id = 1
)t
where
    muc.mesolduslugacomplex_id = t.mesolduslugacomplex_id
;
