开发者

Delete row with a Mysql Trigger

need to do trigger after Inserting on a table called jos_jquarks_quizzes, I need to create a course name which will have the same name as the quizz name , but its own id,

Tables

jos_jquarks_quizzes 

id     title     description     course_id 

jos_jquarks_users_training   
id     quiz_id     user_id     agree 

So far My Trigger looks like this but has an error

-- Trigger DDL Statements
DELIMITER $$

USE `db_dhruniversity`$$

CREATE
TRIGGER `db_dhruniversity`.`ai_delete_course`
AFTER DELETE ON `jos_jquarks_开发者_运维百科quizzes`
FOR EACH ROW
BEGIN    
DELETE FROM jos_jquarks_courses
WHERE (quiz_id = new.id); 
END$$


In your where clause change new.id to old.id

-- Trigger DDL Statements
DELIMITER $$

USE `db_dhruniversity`$$

CREATE
TRIGGER `db_dhruniversity`.`ai_delete_course`
AFTER DELETE ON `jos_jquarks_quizzes`
FOR EACH ROW
BEGIN    
DELETE FROM jos_jquarks_courses
WHERE (quiz_id = old.id); 
END$$
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜