php - MySql Trigger for Updating PostCount -
i have 3 datatables: comment, blog , user. don't know triggers in mysql, possible sum counts of every row in comment , blog when new row inserted or deleted? e.g. blog has 3 entries , comment has 5 entries. when delete 1 comment now, should update record 'post' in user 7 counting entries in blog , comment username. comment table rows: id | cdate | edate | author | email |status | content | url | bid | level blog table rows: id | cid | author | cdate | title | teaser | content | url user table rows: id | username | email | pass | posts example trigger comments update event can write slimier triggers other events change highlighted values drop trigger if exists comment_delete; delimiter $$ create trigger comment_delete after delete on comment each row begin update user set posts=posts-1 id=new.author; end$$