Hey guys.

Is is possible, when using MySQL triggers, to avoid having an operation occur for every row that has been affected by the operation.

For example:
Code:
 CREATE TRIGGER students_create
 AFTER INSERT ON students
 FOR EACH ROW
 UPDATE stats SET total = (SELECT count(*) FROM students)
The update query has to be called each time a student is added to the database. Now, if there are 100s of students added, then that's 99 useless queries.

I could use a total = total + 1 update, but that would consist of 99 useless queries.

Any ideas to avoid using "FOR EACH ROW"? When I try to remove it from the creation query the MySQL client throws an error. Also in the mysql documentation it looks as if it ALWAYS has to be included.

Any ideas?