update oo set oo.C_FOGLALKOZASID = NULL from T_ORARENDIORA oo inner join T_FOGLALKOZAS f on f.ID = oo.C_FOGLALKOZASID and f.TOROLT = 'F' where oo.TOROLT = 'F' and oo.C_TANARID <> f.C_TANARID