I am trying to create a trigger which will update the grades of all the friends of a student whose grade is updated.
create trigger upgrade
after update on Highschooler
when new.grade=old.grade+1 and trigger_nestlevel() < 2
begin
update Highschooler
set grade=new.grade
where ID in (
select ID2
from Friend
where ID1=old.ID
)
;
end
friends of friends (of friends...) of the person whose grade is increased are also being 'upgraded' how can i stop this?