Jump to content

Recommended Posts

Guest orb123
Posted

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.

Guest orb123
Posted

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.

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...