I have a database with two tables: Category and Team, the relationship between the tables goes like this: a category can have many teams. I have created a trigger so that at the moment of inserting a team a quantity field of the category table is added to 1. The trigger goes like this:
create trigger Actualizar
on equipo for insert
as
update categoria set cantidad = cantidad + 1
from categoria, equipo
where categoria.id = equipo.categoria;
The first team works well increases 1, but at the time of inserting another team with different category, the amount increases by 1 for both the new and the previous.