Guest orb123 Posted July 7, 2013 Share Posted July 7, 2013 Hi, I was wondering how I would add a trigger to a delete a row from forum_replies when a topic is deleted from forum_posts? Thanks for your assistance. Quote Link to comment Share on other sites More sharing options...
Ice IT Support Posted July 8, 2013 Share Posted July 8, 2013 This should help http://dev.mysql.com/doc/refman/5.0/en/triggers.html Quote Link to comment Share on other sites More sharing options...
Guest orb123 Posted July 8, 2013 Share Posted July 8, 2013 Hi, I am failing to understand. I ran the following SQL query DELETE [LOW_PRIORITY] [QUICK] [iGNORE] posts_forums[.*] FROM replies_forums [WHERE id=postid] But it returns #1064 - 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 '[LOW_PRIORITY] [QUICK] [iGNORE] posts_forums[.*] FROM replies_forums ' at line 1 Any help would be greatly apperiated thanks. Quote Link to comment Share on other sites More sharing options...
Ice IT Support Posted July 8, 2013 Share Posted July 8, 2013 Try this DELIMITER $$ USE `db_name`$$ CREATE TRIGGER `db_name`.`delete_forum_replies` AFTER DELETE ON `forum_posts` FOR EACH ROW BEGIN DELETE FROM `forum_replies` WHERE (id = old.id); END$$ Be sure to change db_name to your database name and check table names (forum_posts and forum_replies. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.