I have this trigger, but I want to make it count before adding to see if the data already exists in the table so I do not add it twice.
AS
begin
if (new.cantidad <= new.catidad_minima ) then
insert into comprar (nombre_producto ,cantidad,idcategoria)
values (old.nombre_producto,new.cantidad,NEW.id_categoria);
if (new.cantidad >= new.catidad_minima) then
delete from comprar a
where a.nombre_producto = new.nombre_producto;
end