update tcs set TOROLT = 'T', MODIFIER = 0, LASTCHANGED = GETDATE(), SERIAL += 1 --select tcs.ID, tcs.created, i.C_AZONOSITO --, * from T_TANULOCSOPORT tcs inner join T_OSZTALYCSOPORT ocs on ocs.ID = tcs.C_OSZTALYCSOPORTID and ocs.TOROLT = 'F' inner join T_OSZTALY o on o.ID = ocs.ID and o.TOROLT = 'F' inner join T_INTEZMENY i on i.ID = tcs.C_INTEZMENYID and i.TOROLT = 'F' where tcs.TOROLT = 'F' and not exists (select 1 from T_TANULOTANUGYIADATOK where C_TANULOCSOPORTID = tcs.ID)