﻿UPDATE oo
SET
   oo.C_FOGLALKOZASID = null
  ,MODIFIER = 0
  ,LASTCHANGED = GETDATE()
  ,SERIAL += 1
FROM T_ORARENDIORA oo
  INNER JOIN T_FOGLALKOZAS f ON f.ID = oo.C_FOGLALKOZASID AND f.TOROLT = 'F'
  INNER JOIN T_TANEV tn ON tn.ID = oo.C_TANEVID AND tn.TOROLT = 'F'
  INNER JOIN T_INTEZMENY i ON i.ID = oo.C_INTEZMENYID AND i.TOROLT = 'F'
WHERE oo.TOROLT = 'F'
  AND oo.C_TANTARGYID <> f.C_TANTARGYID


UPDATE oo
SET
   oo.C_FOGLALKOZASID = null
  ,MODIFIER = 0
  ,LASTCHANGED = GETDATE()
  ,SERIAL += 1
FROM T_ORARENDIORA oo
  INNER JOIN T_FOGLALKOZAS f ON f.ID = oo.C_FOGLALKOZASID AND f.TOROLT = 'F'
  INNER JOIN T_TANEV tn ON tn.ID = oo.C_TANEVID AND tn.TOROLT = 'F'
  INNER JOIN T_INTEZMENY i ON i.ID = oo.C_INTEZMENYID AND i.TOROLT = 'F'
WHERE oo.TOROLT = 'F'
  AND oo.C_TANARID <> f.C_TANARID


UPDATE oo
SET
   oo.C_FOGLALKOZASID = null
  ,MODIFIER = 0
  ,LASTCHANGED = GETDATE()
  ,SERIAL += 1
FROM T_ORARENDIORA oo
  INNER JOIN T_FOGLALKOZAS f ON f.ID = oo.C_FOGLALKOZASID AND f.TOROLT = 'F'
  INNER JOIN T_TANEV tn ON tn.ID = oo.C_TANEVID AND tn.TOROLT = 'F'
  INNER JOIN T_INTEZMENY i ON i.ID = oo.C_INTEZMENYID AND i.TOROLT = 'F'
WHERE oo.TOROLT = 'F'
  AND oo.C_OSZTALYCSOPORTID <> f.C_OSZTALYCSOPORTID
