Reputation: 666
Please can someone explain what is the syntax error in the following mysql command to create the trigger
create trigger comment_on_network
after insert on network_comments
for each row begin
declare @ansh INT(2);
set @ansh=(select count(*) from network_comments where
network_comments.network_id=NEW.network_id);
update networks set networks.no_of_comments=@ansh where
networks.network_id=NEW.network_id;
END;
Upvotes: 0
Views: 37
Reputation: 77876
Not sure about any error but the below line to set @ansh
set @ansh=(select count(*) from network_comments where
network_comments.network_id=NEW.network_id);
should be
set @ansh := (select count(*) from network_comments where
network_comments.network_id=NEW.network_id);
Also, don't think this declare statement needed declare @ansh INT(2);
Upvotes: 1