MySQL Forums
Forum List  »  Triggers

Need help creating a trigger
Posted by: Rob Rowsome
Date: November 17, 2008 02:34PM

I am trying to create a trigger that updates a different table on insert.

create trigger recalc_post_count after insert on posting
update thread set post_count = (select count(*) from posting where thread_id = new.thread_id) where thread_id = new.thread_id;

I get this error message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'update thread set post_count = (select count(*) from posting where thread_id = n' at line 2

I'm using MySQL version 5.045

Why won't this work? Am I not allowed to update a different table from the one the trigger is on?

Thanks,
Rob

Options: ReplyQuote


Subject
Views
Written By
Posted
Need help creating a trigger
3486
November 17, 2008 02:34PM
2007
November 17, 2008 04:57PM
1951
December 24, 2008 04:44AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.