Guest orb123 Posted July 7, 2013 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.
Ice IT Support Posted July 8, 2013 Posted July 8, 2013 This should help http://dev.mysql.com/doc/refman/5.0/en/triggers.html
Guest orb123 Posted July 8, 2013 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.
Ice IT Support Posted July 8, 2013 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.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now